Memory holds what is currently running; storage holds what is saved. An out-of-memory message means the first is full, regardless of how much space the second has.
Systems extend memory by using part of the drive as overflow. When that overflow area is also constrained — by a full drive or a fixed size — the error appears sooner.
A single program can exhaust memory on its own. Editing very large images, opening huge spreadsheets, or a leak in a long-running application will do it while everything else looks idle.
The distinction matters because the fixes differ. Closing programs helps immediate pressure; adding memory raises the ceiling; freeing disk space only helps the overflow area.