Both prepositions have many, many uses, but basically 'to' goes with verbs of movement ('I went to school at 9 AM') and 'at' goes with verbs of location or situation ('I was at school until 3 PM').
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.