Transaction verification vs block mining
The connected peers do the first one. If it is invalid, they don't relay to other peers and the transaction gets forgotten. If it's valid, then peers relay it to their peers and then miners include the transaction in their block.