'To' can be either a preposition or an infinitive marker.* They're hard to distinguish because they're identical in form.
'To' as a preposition is normally part of a phrasal verb:
I'm looking foward to meeting you. ('to' is part of the idiom 'to look forward to'.)
It can also be a pure preposition expressing a direction or a way to obtain something. For example:
A guide to teaching English.
'To' as a preposition takes a noun phrase or a gerund as a complement. So your reasoning is right.
When used as an infinitive marker, 'to' is followed by the 'plain' infinitive form of verb. This infinitival 'to' normally introduces a clause functioning as a purpose adjunct. You can usually add 'in order' before the word 'to'.
They joined forces (in order) to fight their common enemy.
*It's usually called a subordinator because it heads a subordinate clause. I prefer to avoid this fancy term, however.