Hi!
This is going to be known as being a hypocrite. The most common example of this is the classic saying 'Do as I say, not as I do'.
For example, someone may tell you not to smoke while they smoke themselves. This makes them a hypocrite.
Hopefully, this helps! =)