In short
Nine times out of ten the printer has lost its Wi-Fi connection or received a new address from the router, under which the computer no longer finds it. First aid: unplug printer and router for 30 seconds, switch them back on, check on the printer whether it is in the Wi-Fi. If that does not help, remove the printer on the computer once and add it again. A fixed address for the printer in the router fixes it for good.
First aid in five minutes
Before you touch anything on the computer: printer off, unplug, wait 30 seconds, plug back in. Same with the router. Then print a test page on the printer, via the menu on the device itself. If the test page comes out, the printer is fine and the problem lies between it and the computer. If it does not, the printer usually reports what is missing itself: paper, ink, cover open.
Is the printer in the Wi-Fi at all?
Almost every printer can print a network info page from its menu. It shows which Wi-Fi it is connected to and which address it has. If it shows a different network name from your router, or "not connected", it has to rejoin the Wi-Fi, most easily via the manufacturer app (HP Smart, Canon PRINT, Epson Smart Panel, Brother Mobile Connect). Careful with routers that have two network names: many printers only handle the 2.4 gigahertz network, not the one with "5G" in the name.
On the Windows PC
Open Settings, Bluetooth and devices, Printers and scanners, and click your printer. If it says "Use printer offline", switch that off. Open the print queue and delete all stuck jobs, a single faulty one blocks all that follow. If it stays offline, remove the printer here completely and add it again, Windows then searches the network and sets it up afresh. The manufacturer app often does this more reliably than Windows itself.
On the Mac
System Settings, Printers and Scanners: remove the printer with the minus button, then add it again with plus. The Mac finds printers in the same Wi-Fi via AirPrint by itself, without installing drivers. If the printer appears in the list but shows "Paused" or "Stopped", a click on "Resume" in the queue is enough.
To make it stop: a fixed address
The router hands out addresses to all devices and may reassign them after a few days. The computer, however, remembers the printer's old address and calls into the void. The solution is a fixed address: in the router you can set the printer to always get the same one, on a FRITZ!Box for example under Home Network, Network, click the printer, "Always assign this network device the same IPv4 address". After that the problem is usually gone for good.
Two more small things: move the printer closer to the router if it sits in the farthest room, and set the power saving mode in the printer menu so it does not drop off the network completely after ten minutes. Some devices do not report back from deep sleep.