Airports are split into "landside" and "airside". These are separated by security. In almost all airports you can enter and leave the "landside" area at any time.
In order to get into the secure (or "airside") area, you need to have checked in for an actual flight and have a boarding pass. Then you need to go through security where they will check your boarding pass and ID before you can enter.
In most airports you can simply walk out of the secure area by following the signs towards "EXIT" or "Ground Transportation". To re-enter you will have to go through security again.
Things are more complicated if you have an international flight and need to pass through exit immigration. To leave the airport without flying you will have to go through entry immigration again.
CAVEAT: It's always possible that there entry controls at the airport entrance. These can be triggered by Covid or specific or general security concerns. It's rare but it happens. In this case you will not allowed into the airport without some proof of a flight booking. However, you can always leave once you're inside.