why the transformer rating is in KVA and not in Kw

They do not consume any Power. Basically, we can say that transformers are used to transfer Electrical energy.
When a manufacturer designs a Transformer, He knows about the voltage rating of both the Primary and secondary sides and he also knows the Current through its windings. But he doesn’t have any knowledge about the power factor of the Load.
This is because, we do not know that which load is going to connect with the transformer and what will be its power factor.
For example, a transformer can use to supply an Inductive load like a fan. And it can also be used to supply a resistive load like Iron or heater.
We know that both types of load have different power factor and we can not determine that which particular load is going to connect with the transformer.
So, the manufacturer can not predict the type of load and hence he doesn’t know anything about the power factor of the load. So, he can not give the rating in kW (as power factor cosɸ is needed to find power ratings in Watts).
In this way, the Power rating of the transformer is given in kVA, not in kW