That's actually a good question that made me think :D I would say this phrase comes from "La tercera (vez) es la vencida" (literarily "the third time it's the overcome one"), or "La tercera vez será la vez que vamos a vencer", which doesn't sound very good like that, but could be thought as "En el tercer intento vamos a superar el problema" = "At the third attempt, we'll overcome the problem". That's what I can think of. This is one of many phrases that we use without even thinking if they make sense.