Ok help me here the -m turns the first part from feminine to masculine
The -m in the past tense indicates 'ja' (first person singluar). A long, long, long time ago this was something like (j)eśm and over time it became -m
In the past (and occasionally now in some types of Polish) this -m (and other past tense first and second person markers) didn't have to follow the verb, for example my former boss (now retired) used to sometimes jokingly ask "Coś zrobił?" instead of "Co zrobiłeś"
In modern Polish the tendency is for the endings -m, -ś, -śmy and -ście to always remain on the verb.
If you look at Czech grammar then Polish grammar makes a lot more sense (the evolution has been different but the modern differences... often show where the modern language comes from)