Anchor Links in Fixed Side Nav are scrolling to random page sections

Hi, I’m working on a fixed left-hand side nav for a project using anchor links to smooth-scroll to specific sections. The weird thing is, sometimes the links scroll correctly (to the top of the blue content-container-header element), then most of the time, the page scrolls to a random part of the page, often very far from where it’s supposed to stop.

I checked and double checked that the IDs are matched, plus the side nav positioning. What am I missing? Is the fixed top nav causing the issues? I have both side nav and top container margins set to the same height as the top nav so it won’t block the scroll-to sections - is that the issue?