@coyohti is correct. The pivot point needs to be set to median point via the drop down as previously mentioned. When extruding and scaling to restrict the transform to a designated axis, such as Z (up and down) after pressing E or S press the Z (or X or Y which ever you need) key to restrict to that axis and the extrude or scale will only transform along the selected axis. Quite often when scaling you may want to scale in two axis but not the third, for example if you want to scale in X and Y but not Z, press SHIFT+Z to exclude Z from scaling.
This is dependent on the transformation orientation as defined next to the pivot point, by default set to global. There is a lot more I could explain, like press Z twice for Local axis, but a good way to learn is to try out different pivot points and orientations and see what happens, you can always CTRL+Z to undo.
🍪Eat cookies and carry on🍪