Serbian is a S-V-O language, like English. This means that the normal word order is Subject-Verb-Object. However, the word order in the Serbian language is free, in a way that most words can be placed anywhere in the sentence.
There are some little words with fixed positions. The short forms of the verb „biti“ (sam si je smo ste su) are amongst them.
These little words are called enclitics. They are unstressed, so they stick to the second position and lean on the previous word, like a crutch. The enclitic and it’s precedent word are pronounced like one word, with the stres on the first word.
That’s why the position of the helping verb and the participle in the past tense is varying: because the participle is a stressed word, not an enclitic.