I want to ask about this issue: believing that if something bad happened to someone it’s because of their previous or recent sins, is this way of thinking aligned with Shia Islam, it feels like it’s a painful way of thinking but I’m not sure if Allah would punish us in this world directly after a sin. Do we have any ahadith in our books on this topic?

Yes we have several verses in the Quran and hadith from the Imams that say the suffering we see in this world is a consequence of our own actions. Sins do have impacts on our lives, our spirits and our physical being is impacted by the way we live our lives.

Quran 2:225
Quran 2:225
Quran 30:41