The fact that the south lost the war does not make secession illegitimate. You seem to be very happy with a mafia mentality - you join the family and you only leave in a pine box - applied to the states.
Texas very specifically swore allegiance to the union and gave up — specifically — the right to secede, after that. That was one of the conditions of coming back into the union.
It’s just the way history went...