Certain trades are obvious winners- index funds available for less than the sum of their component parts for example. Everyone on the street knows they are obvious winners, so usually the trade isn't available for long. Firms have computers set up to constantly scan the markets for these opportunities. Whoever sees the trade first and gets to the exchange first ends up making all the money.
Right so far :-) But the HFTs are not in the game for the long haul; they will immediately sell the stock to another investor, at a price between what the HFT paid for it and what the stock is worth to the other investors. That's why it's high-frequency trading. The buy and sell are almost synchronous.