"Heap Blocks: " Number meaning on Query Plan for a bitmap heap + index scan
4MB was enough to hold references to 2964 heap blocks (plus sub-references to 3531 tuples falling within those blocks).  It doesn't hold the blocks themselves.  The blocks themselves would be held in shared_buffers (Or cycled through shared_buffers if it were insufficient to hold them all), not in work_mem.