Why do some stars orbit the galactic center in that bobbing way?
All stars move under the influence of gravity. Disk stars orbit the center of the Galaxy in the plane of the disk. They also tend to bob up and down: if they are heading on a trajectory slanting down out of the disk, eventually the gravity of the disk will pull them back up. They’ll overshoot, and then bob back down, and so on. The stars just keep going around through the spiral arms (which are density variations).