You don't owe Company A anything until after you have signed and returned the contract. There are many things can can change between the initial interview, and the start date. This is true even if you thought you understood everything.
Some companies will only have vague statements about benefits on their website. But you might not realize until they send you the contract that it doesn't include something. They might not have a good retirement plan, or the health insurance could be very expensive.
You might find that the company wants to put you on a different project or move you to a different location.
The contract should have an expiration date, and a method of accepting the contract. They will most likely followup in a day or two, to urge you to sign. If you want to see a contract from Company B you will have to get them to act fast, or risk having to make a decision at the last minute.
When the deadline is reached for company A you will have to accept or reject the contract. If you reject or let it expire they will move on to the second candidate. If you accept they will wait a day or two and either inform the 2nd candidate the the position is filled, or try to find them a new position.
If you switch to company B after accepting the contract from company A, they will be disappointed, or upset, but are unlikely to sue you. The exception is if they spent additional funds for a background check, or to move you, then they might want to recover damages. I did see one case where the employee accepted a position with the government, but the back ground investigation took over a year. When the government checked back with the employee, they discovered that they had accepted a another government job and didn't want to go with the first agency. The 2nd agency only took 30 days to complete the investigation.
The penalty for backing out will be an inability to ever work for that group again.