A computer doesn't actually "understand" anything. It merely provides you with a way of information flow — input to output. The decisions to transform a given set of inputs to an output (computations) are made using boolean expressions (expressed using specific arrangements of logic gates).
It is up to us (putting it more precisely, the Software we use) to interpret this information based on a given premise. If you're given the binary string 11111111 00000000 11111111 (binary representation of the RGB values (255, 0, 255)) with extra information indicating that it represents a color, your software will interpret it as a signal to display the color Magenta.
Why do computers use binary, anyway?
Coming to the question at hand, modern computers use tiny devices called Transistors to represent the 1s and 0s.
To understand the principle and the working behind them... @mevrael has pointed you to the right video — How does a transistor work? - Veritasium
Here is a great TED-Ed video — How transistors work? - TED-Ed — with a historical overview of how the early computers handled 1s and 0s, the problems we faced, and how the modern-day computers, using transistors, are absolved of these problems.