Okay, take a deep breath. My son was totally like this and I was just as distraught as you. It sounds like it's "normal" hitting. My son did it the same way...sometimes he was mad, sometimes frustrated and sometimes he was so plumb excited he just hit people! It drove me crazy and yes, I was totally "that mom" at the playground who had the kid that hit other kids. Ugh.
I think that honestly, you just have to keep up with the time outs. I know it feels like it isn't working, but you can't just ignore it. At this age, hitting and time out really is just a game for them and it frustrates the heck out of the adults who take it so seriously, but remember that it's normal for a 2 year old to react like that.
Secondly, look for his "tells". Just by watching my son I could totally tell when he was about to hit someone and I would jump in and stop it by either moving him, putting him in time out, something. I was bit of a hoverer for many months, but whatever, it was better to be that than the mom with the out of control kid! ;) And, he's not out of control, he's being a 2 year old boy and you are trying...just keep trying.
I honestly don't know what flipped the switch in my son, I do think it had a lot to do with him being able to speak a lot better, but he will be 3 in September and I haven't had issues with him and hitting for many months now. (Knock on wood!!!!) Take it one day at a time and just stay consistent. He needs to see the consistency from you. Hang in there, though, it will come to an end eventually!