They can do this — or will try to do this — because both the airlines' and booking.com's terms of service disclaim any responsibility for anything except providing, respectively, an airline seat and a hotel room. You will have agreed to these terms when you purchased the ticket and reserved the hotel room.
This is far short of ensuring that you can actually take advantage of the flight or the room. Neither an airline nor a hotel will take responsibility for determining if you can travel. There are far too many use cases and itineraries to keep track of, and the rules change frequently. Imagine keeping track of thousands of passengers and hotel guests whose admissibility can depend upon citizenship, country of residence, type of passport or travel document, possession of visas to 3d countries, etc etc.
Because you could not immediately secure a refund for the hotel room, its reservation was probably non-refundable. In view of the ongoing travel shutdowns, the hotel may see fit to refund your payment, but there are no requirements in contract law or governmental regulation that require them to do so for a non-refundable booking. Sometimes, rebooking for a different date or a voucher towards the cost of future stay may be offered. Again, these too are not required.
All airlines' terms and conditions expressly provide that they are not responsible for issues regarding passports, visas, or a country's willingness or unwillingness to allow you entry or travel in their territory. That you could not travel to the point of departure, or would be inadmissible at the destination country, is not the airline's responsibility.
Each travelers should assess whether the higher cost of a refundable ticket or room is worth the resulting peace of mind. Travel insurance may be a useful investment as well. Many have cancelled travel until the travel and entry situation has settled down, which is likely many months in the future.
Note that this answer is addressed to the situation where the customer wishes to cancel. If the hotel or the airline cancels, on the other hand, the discussion above would not apply.