How do we measure the number of protons, electrons, and neutrons inside an atom? What experiments can be conducted to determine, for example, that an iron atom contains 26 protons?
There are no techniques that directly count the number of electrons, protons and neutrons in an atom. All deductions about basic atomic structure were established indirectly, well before the 1940s with the help of chemical properties and purely chemical measurements of atomic weights. No machines needed except a highly accurate mass balance. One would determine the atomic weight of iron from quantitative chemical reactions.
It will not be wrong to say that it was purely the empirical periodic table led to our basic conceptions about the atomic structure. None of the fancy techniques mentioned in the other answer such energy dispersive X-ray spectroscopy or particle induced X-ray emission were there to count or probe the atomic structure. These are analytical techniques and need calibration, i.e., someone has to tell the instrument that this frequency is associated with a certain element.
Chemists had already deduced chemical properties and arranged them in a "periodic" table showing that chemical properties repeat periodically like periodic mathematical functions more than 100 years ago. The chemical elements, then known, were also roughly arranged according to the atomic weight (or atomic mass today) not by atomic numbers as done today. Physicists started to probe this arrangement deeper and deeper and this is where X-rays started to help explain this periodic phenomenon of chemical properties.
It was young Moseley's X-ray work that established that the ordinal number of the elements (let us call it $Z$) in the periodic table was related to frequency of the X-rays emitted by each element. Since Bohr had established that hydrogen has a Z=1 with one proton, it was Moseley's intuition that led to the proton count of the elements.
By electrostatic theory, the positive charge must be balanced by negative charges. So the number of protons must equal the number of electrons. The last question is number of neutrons: The number is neutrons was deduced, again indirectly, from atomic masses because the mass of the protons did not add up to the atomic mass. Something "else" was there, and this was the mass of neutrons. Mass spectrometry also established isotopes.
So back to your original query: How do we know that iron has 26 protons...it is because of Moseley's law.