hi
thanks for writing to HCM,
shoulder dislocation usually occurs due to inappropriate support provided by the ligaments and muscles around the shoulder
joint.
if your shoulder dislocated in the same direction twice then the above mentioned reason holds true for you as you also explained that second time you were just doing a routine activity i.e. closing a door.
So I would suggest you to see a
physiotherapist who specialises with masters in
musculoskeletal or
orthopedics.
he/ she can tell you specific exercises to strengthen your muscles around shoulder joint which can further prevent the chances of dislocation.
the exercises should be gradual - initially low intensity with moderate repetitions, later on gradually increasing the intensity and repetitions as well.
hope this helps you
wish you good health