Oh yeah, I have a feeling I'm familiar with this, not direct but similar. So basically it's your brain getting a dopamine fix. I understand the lack of control of what the brain has latchedb onto for it's dopamine fix, usually for me it's some technical thing but it has been romantic and also understanding another person and even in a deep and romantic way. I don't know the exact mechanics of your ex relationship.
So perhaps your brain is imagining that if it understands him then you won't have another break up or you'll be more prepared or you'll be able to get him back, whatever it might be. The brain found something t that lifts the dopamine back up. It can happen months after a break up.
For me, I just daydream and imagine up 'what if's' and romantic scenes and stories in my head. I allow myself to wallow in it and it gives me a dopamine boost. I require far less when my meds are on full boost but at the end of the day as it's wearing off, I'll often find myself daydreaming romantic stories again.
My advice would be to flow with it but keep it safe. Kind of like a sandwich box. Don't let it interfere in your life (no stalking etc, lol) but I don't know your circumstances. I do believe I understand and have experienced similar, and probably in different periods of my life to different degrees.
I hope this helps, at least you know you are not alone with this.