In a vacuum triode, what prevents the grid from acting as another anode?
The grid is maintained at a negative voltage with respect to the cathode (similar to the operation of a N-channel JFET, or a depletion mode N-channel MOSFET), so electrons will be repelled by it. A result is that fewer electrons reach the anode, which has a positive voltage with respect to the cathode in order to attract electrons. Whatever small current flows in the grid is considered leakage.
But doesn't the grid also have the ability to capture electrons?
You are correct, it does and some non-negligible current can flow.
However, to get a current the electrons need to actually enter the grid.
If we look at the construction of a triode:
we can see that the grid is just a thin wire, so the chance of an electron hitting (touching) it is small. Most electrons will "miss", travel between the grid's wires and reach the anode.
Depending on the voltages at grid and anode, the "pull" (due to the electric field) on the electrons from the anode might be stronger preventing the electrons from entering the grid.
Apart from tube design specifics (see what is said about grid shapes in other answers), circuit design keeping the grid sufficiently biased negative does.
"Grid current" is a well known phenomenon with vacuum tubes biased well into the positive. Considered part of some power amplifier designs (especially transmitters); obviously, the previous stages need to be able to deal with having to feed that kind of nonlinear load. Considered an overload condition in other designs.