I heard somebody say "come at me". Why does he use the preposition 'at' instead of 'to'? I want to know the difference between 'come to me' and ' come at me'.
Without further context, as an idiom, "come at me" can be used to instigate, provoke, or invite another person to attack or fight. Nowadays, you might hear
Come at me bro!
This dude wants to fight.
Without further context, "come to me" sounds like you are signaling someone to come or move towards you.
In very abstract terms, the preposition at expresses (among other things) movement towards with the intention of striking or making contact, whereas to expresses movement towards with the intention of reaching.
The boxer took a swing at his opponent.
They shot arrows at a bale of hay.
The skunk is ruining our picnic. Toss a stone at it to make it go away.
Toss the ball to me.
They threw a life-line to the struggling swimmer.
He drove his friend to the airport.