I will give you an example of Family visa - may be this would help you understand about your case.
When we bring family on Visit Visa and while they are in country you can in parallel apply for Family RP. Once this RP is approved, there are 2 options.
1. The family has to quit the country and enter with the new RP visa
2. The family can still stay in the country without exiting while you can convert their visit visa to RP Visa by paying penalty of 500 QAR per head in immigration department. By doing this, the visit visa stands cancelled and it shows that the person has entered using Family RP visa. After this process you can go ahead with other formalities like medical test & finger print.
Now, with the above scenario, your new employer might have not done this and that is why your visit visa still shows active and you had to pay the penalty.