Relock after few weeks

Hello,

i need help, i did unlock to my samsung phones T-mobile carriers
after few weeks the phone locked again
some phones relocked some phones work good,

what i need to do to prevent the relocks? maybe write some certificate?