My paper was accepted for publication in a journal. I have also received an acceptance letter and even I have filled out the copyright form. The corresponding editor first told me "Your paper is published in one of the volumes of 2017" and next time said that my paper is "published in 2018", but now I have received an email that my paper is "rejected because the paper is not in the aim and scope of the journal"!!!
Really I do not know, what should I do?
This is unacceptable. If this is a reputable journal, then you can make the point that they made you wait and the research results become stale, and that you have every right to expect them to honour their approval for publication.
They simply cannot retroactively change whether the paper fits into aim/scope of the journal - that decision had been taken with acceptance. If they made a mistake in judgement, you cannot be expected to be the person to bear the cost of this.
If the journal is not reputable, you probably dodged a bullet - and if it is "reputable", and they insist on not publishing your paper after this protest, you can be assured that they are on the way to becoming not reputable, fast (I would, however, not make this point in your protest email).