I hate getting flashbacks from things I don't want to remember

The best way that I can explain this is unless my mind is absolutely set and happy with my life all around 100% -whenever I have a,''huh, imagine that'' moment and stare off into space trying to ''imagine it'' I see flashbacks to hitting my head all of the time, smacking, bleeding, or past abusive relationships

My best solve for this is a packed schedule all around but then I start seeing the flashbacks in my dreams and wake up in panic attacks when I don't panic anymore when I have flashbacks awake. I just take medication for sleep and daytime anxiety again and deal when awake