>>56235110TMs are applied to a pokemon's pokeball while the pokemon is inside it.
A TM is muscle memory recorded onto a disc, the main purpose of TMs is to grant knowledge of how to manipulate type energy that the pokemon doesn't normally know.
You can train your pokemon to learn it the hard way, but it's time consuming and difficult for both of you. A trainer doesn't understand what a pokemon does to create a Thunderbolt and neither does a Persian know how to even start creating electric energy. A TM lets you skip the first step which is the hardest.