While learning about computers I will read about RAM and Storage and the CPU, and while these explain the architecture of a computer and how parts of a computer work together, I still don't understand the fundamental workings of a computer program.
Let me take an example.
I'm on the web on a mac right now. When I push two fingers away from me on the trackpad, I understand that the trackpad is made up of a capacitive touch screen that, when your finger is placed on it, draws current and the trackpad detects that and converts it into data that explains the movement of my fingers up the screen.
However, when you have this data in binary form, or machine code, it goes through logic gates and other things to make it in scroll down on the page. But what is actually happening here? How would the computer have physical things that operate differently based on the input? What operations are carried out on the machine code that says "if data looks like 01001010 10101010... send instruction 10010010... to CPU that tells computer to scroll down". Surely if you had some logic gates that turned input x into output y, yes they would give different outputs based on the input, but unless you somehow redirected the current to the right set of logic gates every time the action was carried out, how would it go to the correct one? To me this step is still magic. Especially with computers now that have no moving parts it seems even more alien.
Could someone explain this to me?