Hi Avery! Apples brown due to a chemical reaction called oxidation. You may recognize the “oxi-“ part of that word. Oxygen is what causes this reaction to occur, which is why it’s part of the name of the reaction.
There are special chemicals in the apple that are naturally occurring and these react to oxygen when they are exposed to it. When you cut open an apple you allow a lot of oxygen in. The special chemicals are colorless but when there is a lot of oxygen, these chemicals become brown in color.
Like you said putting something like lemon juice on the apple prevents browning from occurring. This is because the lemon juice contains other chemicals that stop the browning reaction from occurring.