The difference is between two different uses of the verb to aim. One is literal and means to direct something at a target while the other is more figurative and means to have the intention to carry out a course of action or achieve a certain goal.
In the first case this means that we can say "I saw a man holding a gun, the gun was aimed at me"; "The stone was aimed at the window but fell short and landed in the garden"; "I aimed a punch at his head" or even "In the computer game I aimed my mega blaster at the alien". In all of these there is a more or less real target (even though the mega blaster and the alien only exist on the computer screen or VR headset) so we say aimed at.
In the second case we can say "When I graduated from university I aimed to have a career in the financial sector"; "I set off early in the morning aiming to walk to York by nightfall"; "When I struck out I aimed to knock his hat off" or even "When I began to play the game I aimed to beat my brother's score by killing more aliens than he did". In all of these examples there is an intention which has been formed in the person's mind and the aim is to complete the action or achieve the ambition even though the intention in the case of the hat is very short term. Because the aim in these cases is an intention rather than a physical action we say aim to.
Note that, in order to knock off the hat, I would have to aim at it in some way but that is to do with the physical action I would take in order to achieve the more abstract goal of knocking it off.
As an aside there is also the form aim for. This is rather more like aim at than aim to but the targets can be less well defined. It can be used in sentences like "I aimed for his hat but missed and struck him above his left eye". "After graduating from university I aimed for a position as an actuary". Note these examples are more specific than the aimed to examples but are less concrete than the aimed at examples.