1. How do we get the number of protons now?
For charge neutrality, the number of electrons has to equal the number of protons. So, the question really is how to know how many protons and how many electrons. This is actually a very interesting question dating back to the early days (and even before) of nuclear physics and chemistry.
Now, one can do it fairly easily with an ion accelerator and a magnet. With the right set up, one can get a beam of mono-energetic ions out of the accelerator, send them through a stripper to remove electrons, and then send them through a magnet to separate the components out by velocity (which depends on the ion mass through the energy). From the magnet deflections, one can get charge-to-mass ratios, and get back to the number of protons (charge on a fully stripped ion) and the number of neutrons (from the number of protons and the mass). This is the heart of mass spectrometry (although one can use time-of-flight techniques rather than, or in addition to, magnetic separation).
Back then chemists agreed that hydrogen is basically one positive and one negative ie one electron and one positive particle and then all the other elements were taken as ratios with respect to it.
2. How did Mendeleev know atomic numbers?
Mendeleev didn't consider atomic numbers. He worked with atomic mass and arranged the elements based on atomic mass. Then came Henry Moseley with Moseley's law
wherein he established the atomic number of protons as a more fundamental property.