If your vehicle is not 4 wheel drive, your only hope is flotation in your tires, ie, wider tires, lower air pressure, etc. In California, the only beach where it’s legal to drive on the beach is Pismo Beach, and thousands do. You can even camp on the beach too at Pismo, though I stay in the campground right off the beach as the party crowd stays on the beach. Don’t know about other beaches, but there is usually a hard packed area on the sand leading to the beach that forms sort of a “path” that is hard enough to drive any vehicle on, ie, 4 door sedan, etc. The sand close to the water is hard packed too so any vehicle can drive along the water. If you get in the soft sand away from these hard packed areas you WILL get stuck unless you have a 4 x 4 and run low pressure in your tires. There’s usually somebody around that can pull you out if you get stuck.