How do you end up with sarcoidosis?

Not predictable. This disease occurs spontaneously, but higher incidence if you have a relative with it, or if black or scandinavian background. Often involves lung and lymph nodes but may affect many other organs including eyes, skin and kidney. Mild diseases may resolve spontaneously, but some require specific treatment depending on extent and location.
Genes + environment. Not known for certain why some people get sarcoid. We know certain groups (scandinavians) and african americans are at increased risk. Maybe combination of genetics + some viral infection or environmental exposure. Altered immune function or response to germ or environment initiates it.