Situation when you close the map while dragging compass (or other map tools, vanilla/mods) appears quite often also it occurs with alt+tab
The next time you open a 2D map compass will 'stick' to the cursor until you click on any part on map, preventing you from drawing a marker on the map asap
see YT video (after close map LMB was not hold more)