It is caught by sharing the virus (which is found in the body fluids of an infected person). Penetration can cause small fissures in the tissues of either or both people, which can then allow the virus to cross over in the ejaculate or blood. HIV can be passed along in vaginal, anal, or oral sex. (Actually every STD can be passed along during any of those, also.)
So be smart, and if you decide to 'get it on', use protection.
They ^ basically said it all 1_~