Why do they do this?
Much like dogs, cats will seek out water if they do not have any readily available. If you cat doesn’t have fresh water, he/she will go looking for it and water is always in the toilet. They tend to remember this after doing it a few times and make a habit of going straight to the toilet when they are thirsty.
How can I correct this behavior?
You must first understand this is not a behavior you want to correct. Finding water sources is a natural instinct for cats. It is not something they should ever be punished for doing. If your only option for water was to drink from a toilet or be without fluid, you would do the same! It is simply a survival instinct.
What you want to do is make sure your cat ALWAYS has fresh water sources. It is best to have at least two they can easily reach. Some cats will not drink from bowls where their whiskers touch the sides so be sure it is wide enough. You can also choose the option of using running water and buy a pet fountain. This way they will always hear and smell the water. Moving water is also more appealing to cats. Kittens and elderly cats seems to go to the toilet bowl more than adult/middle age felines. This could be because of memory issues or ease or use. For kittens you simply remove them from the toilet bowl, put them on the ground next to the toilet, and flush it. This should scare them enough to not want to be near it again. Be sure the door is open so they can run out. You want them to be scared of the toilet, not the bathroom! Elder cats are more stubborn because they are used to the sound so it is best to just keep the toilet lid down.
Is it safe for my cat to be drinking that!?
If your toilet area is kept clean, you don’t have to worry about your cat digesting the water. Cats have far superior bacteria in their mouths to handle eating raw meat and natural/unclean water sources in nature. Just make sure to never have chemicals or chemical residue in or around the toilet.