@Elías *******
That’s not correct. At all. A visa is "permission to knock on the door". It does not guarantee admissibility nor does it absolve the carrier of responsibility in the case of inadmissibility.
If Thailand denies entry (including on a valid visa), you are not free to go anywhere. You are kept airside / in immigration holding and returned to the last point of embarkation.
The airline is responsible for transporting you back. This is standard international carrier-liability law.
Sources:
• IATA – Carrier Liability (inadmissible passengers)
• ICAO – Responsibility of carriers for inadmissible passengers
• Thai Immigration Act B.E. 2522 (1979), Section 12 & 19