The answer depends on what you mean by "baseboard".
Where you have a separate baseboard and shoe molding, then you would
install the baseboards, then the carpet and then the shoe molding (if
you choose to install shoe moldings).
The reason for that is because when you install carpet, you use a tool
called a "wall trimmer" to cut the carpet about 1/2 an inch before the
baseboard, depending on the size of the carpet, and then stretch the
carpet the rest of the way to the baseboard. The wall trimmer needs to
slide along a straight and preferably vertical surface, and often the
bottom of the drywall will be an inch or so off the floor, and that can
cause problems with the wall trimmer.
However the reason builders will typically install single piece
baseboard first is that the wood trim (like baseboards and door casings
and such) are generally the last thing to be done when building a house.
So, in the interest of saving time and money, the builder is going to
want his finish carpenters to put the baseboards in before they leave
the job site. That's cuz if he calls the finish carpenters to come back
to install the baseboards AFTER the carpet is installed, then he has to
have the carpet cleaned cuz of all the sawdust tracked all over it.
But, really the bottom line is that if you have a smooth vertical
surface along which you can slide your wall trimmer, you can slide it
along a baseboard just as easily as sliding it along the drywall, so it
really doesn't matter.
When I install carpets in my building, I stretch the carpet up to the
baseboard and then install the shoe molding to cover the cut edge of the