Things work because their fundamental forces allow them to. To better understand how something works, that thing may be made into the subject of a physical experiment. Discovering how a thing works is done through scientific experimentation or through observing it and making an informed assumption of the thing's properties and functions. Sometimes, a thing seems to function one way but may work differently than first expected or have workings that are not easily spotted on the surface.
Discovering how a thing works is comprehensively discovered through the scientific method. First, a scientist asks a question about the thing. Then, he does research into the thing, such as where it came from or how old it is and what observations have already been made, and constructs a hypothesis around this research. Then he subjects the thing to numerous tests to try to prove the hypothesis, a kind of educated guess, about the thing. Finally, he makes his conclusion, determining how close his guess really was, and he tells others about how the thing works.
The best way to discover how things work is to consult the publications of scientists and engineers or other experts familiar with the thing in an intimate manner. Even scientists are not completely sure how everything works, though, so a final assertion can be made: No one really knows how things work.