When I cough something under my ribs in my right side pops out of place what could make this happen?

Rib cartilage. Sounds as though you are popping some rib cartilage. The ribs are joined to the sternum by cartilage. With coughing and moving the abdominal wall against the upper body, something has to give and it is the cartilage. Kinda like cracking the knucles.