In the first episode of To Aru Majutsu no Index, Misaka attacks Touma with her Railgun, but she deliberately misses him. After that she attacks him with her usual lighting attack but he nullifies it with his power. But why did Mikoto attack him? It's so unlike her to attack somebody that innocent. (Yes, she does always attack some people, but they usually pick a fight with her first.)
The two have met before Index, in Toaru Kagaku no Rērugan (A Certain Scientific Railgun) Misaka encountered Touma and his ability to nullify her attack with his Imagine Breaker in his right hand. When Misaka asked how Touma did it he says he doesn't know yet Misaka doesn't believe him.
This annoyed Misaka because she's one of the strongest Espers in the city (one of only a handful of Level 5's) and she's proud of it, Touma is a "Level 0" so he shouldn't be any match for Misaka however she can't win against thanks to Touma's Imagine Breaker and without knowing how it works Misaka can't accept that she is bested by him.
In Index they already know one another, it's just that after Episode 6 of the Index Anime Touma acts as if he doesn't know her because his memory was wiped out from a feather that remained after the effects of St. George's Sanctuary when Index was in Johann's Pen Mode.
The actual reason behind Misaka's attacks is quite simple. It is played for pure comedic purposes. Tsunderes act out of character near their crushes - a common trope found in anime. Basically, Misaka was worried about how a level 0 like Touma could deflect her attacks. She thought that she must be missing something, and the same tactic might be used against her by criminals. Attacking Touma again and again would probably help her realise her probable 'weakness' and whatever strategy he is using (since he never disclosed the truth initially). Since they became closer, Touma became one upon whom Misaka would vent her emotional frustration, and ends up fighting him. It does not help very much then, when Touma teases her in the process, making her feel more insecure. The last reason, from Touma's perspective, is bad luck. To Aru Majutsu no Index confirmed that he was BORN to be misunderstood.