It can be an infinitive marker, used to show that the
next word is an infinitive (e.g. to swim, to laugh).
It can also be a preposition, followed for example
by a noun.
(e.g. She's gone to the park, I look forward to Christmas).
When to is a preposition, it can be followed by
the -ing form of a verb, but not normally by
Common expressions in which this happens are:
look forward to, object to, be used to,
prefer (doing one thing to doing another),
get round to, in addition to.
In the following examples, note how the
preposition to can be followed by either
a noun or an -ing form.
I look forward to your next letter.
I look forward to hearing from you.
(not ... to hear from you.)
Do you object to Sunday work?
Do you object to working on Sundays?
I'm not used to London traffic.
I'm not used to driving in London.
I prefer the seaside to the mountains.
I prefer swimming to walking.
I'll get round to the washing up sooner or later.
I'll get round to doing the washing up sooner or later.
A few verbs and adjectives are used with to before nouns,
but are followed by the infinitives of verbs.
Examples are agree, consent, entitled, inclined, prone.
She agreed to our plan. She agreed to do what we wanted.
He's inclined to anger. I He's inclined to lose his temper.
Accustomed can be followed by to + -ing form or an infinitive