How is a semiconductor electrically neutral?
Take silicon as an example. Silicon has four valence electrons, and silicon atoms in a crystal lattice form four bonds with neighbouring atoms.

Transistors, and other semiconductors, are made of silicon crystal with small amounts of dopants added. These dopants change the electrical properties because of the way they interact with the crystal lattice. Phosphorous, for example, has 5 valence electrons. It's still electrically neutral (number of protons = number of electrons) but since the silicon crystal structure only requires 4 bonds per atom, there is an 'extra' electron that isn't really participating in the crystal structure. With a bit of extra energy, that electron will go into the conduction band and freely roam around the crystal lattice. This corresponds to an n-type semiconductor.

There is a similar process for p-type semiconductors - boron, for example, only has 3 valence electrons.