That would either be insubordination, dereliction of duty, or going AWOL, depending on the exact context. All of those can buy you a court martial and potentially some time in military prison, as well as fines and other punishments.
You've probably heard at some point about people volunteering for deployments, which is a thing that happens, but only on a "Volunteers get first dibs" basis. If they don't have the numbers they start tasking people and you absolutely do not get to say no. That's why you swear an oath. It's not a regular job, they own your ass. During actual conflicts like this they even get to keep people on after their contracts are up, if it's required for "operational tempo."
Oh, actually, here's an additional fun fact (provided by one of the serving military members I showed your previous comments to, after they were done laughing their asses off); when you're overseas on an operation you travel on a military passport, which is kept locked up by the orderlies, and even if you got it back somehow you'd need travel orders to use it. Airports will literally refuse to board you on the plane if you don't have paperwork saying you're not AWOL. It's not only illegal for these guys to go home, it's also basically impossible.