First, separate the two symptoms. A washer that won't drain and a washer that won't spin feel like the same problem, but most machines refuse to spin as a safety response to water still in the tub. Fix the drain and the spin usually returns on its own.
The most common cause by far is a blocked pump or filter. Socks, coins, hairpins, and the corner of a fitted sheet all end up in the same place. On front-loaders there's usually an access panel at the bottom front with a filter you can open yourself — put a towel and a shallow pan down first, because more water comes out than you expect.
If the filter is clear, look at the drain hose. A hose kinked behind the machine, or pushed too far down the standpipe so it siphons, will produce exactly this symptom. In basement laundry rooms the standpipe itself is often the problem: years of lint and detergent narrow it until the pump can't push water out fast enough.
When the pump is clear and the hose is fine, you're into parts. A drain pump that hums but doesn't move water, a door lock that never confirms the door is shut, and a worn belt or coupler on the drive side all show the same face. A control board can also stop calling for the pump at all — less common, but it happens on machines that have taken a power surge.
One repair we always talk clients out of on older machines: drum bearings. If the tub grinds and rocks and the bearings are gone, the labour is most of a day and the part cost is real. On a machine over ten years old that's usually the moment to replace rather than repair, and we'd rather say it up front than take the job.
