The rule is that those type changes must be temporary. In addition to Meloetta, whose type change reverts on switch-out, you can also get Pokemon of other types by using Protean/Libero. Similarly, Reflect Type, Camouflage, Conversion, and Conversion 2 are perfectly legal. Even more relevantly...