If we're in a good program, we're receiving valuable training both in our coursework (or before PhD in an MS/MA if your country does it that way) and in our research work. Ideally, we're building up a network of collaborations and acquaintances in the scientific community that gives us an "in" for the next stage of our career, while also being mentored by world-class experts in our fields.
In a not so good program, we're used as TAs for a few years and then rapidly encouraged to drop out.
Either way, most of what we do is not like most of what an undergraduate student does. It is like what an entry-level professional does.