I know the question is quite old, since it was first asked here : QGIS map composer changing legend position when exporting atlas as images and here : QGIS composer changing legend position when exporting, but I'm having the exact same issue on QGIS 3.10, and no answer seems to work for me. since the questions were pretty ancient I thought that I should ask a new one.
I'm working with an atlas and themes to have a set of maps somehow automated. The legend is different for each page of the atlas, and so is the height of the legend. Therefor, I checked the "Resize to fit contents" box and the "Show contents inside current atlas feature" box
My legend is meant to be on the bottom right corner of the page. so I choose the bottom right corner of the legend as an anchor, positioned my legend. everything is great on the composer, the legend adapt itself but stays at the bottom right corner where it belongs... but when I export, it goes completely random.
I tried to change the Anchor (bottom right, bottom left, bottom middle), I tried to fix the X and the Y(as suggested on the others threads), but it still doesn't works...
I can't provide images of the map or the project since I have a confidentiality agreement, but I can edit to add picture of the property tab (in french) if it's useful.