Good question as you can actually undersample and oversample at the same time! See my "DSP Puzzle" question on that specifically here:
How do you simultaneously undersample and oversample?
To best explain undersampling and oversampling, it is worthwhile understanding the concept of "Nyquist Zones" first. This was explained in detail recently at this post:
Higher order harmonics during sampling
From which I am copying some graphics for further explanation here.
Sampling in the 1st Nyquist Zone, as in the graphic below, occurs when the real analog signal is located anywhere in the frequency range of DC to half of the sampling rate. Sampling at twice the highest frequency (and actually twice the highest bandwidth, as we will see more clearly when describing "under-sampling") is the minimum necessary condition to capture all information within that bandwidth according to the Nyquist-Shannon theorem. In practice to allow for achievable anti-aliasing filtering in the analog we need to sample a little higher than this, typically 20 to 30%.
The graphic below shows the related processing spectrums when sampling an analog input signal that is in the "first Nyquist Zone". The colors are related to other discussion that is detailed in the link I gave above but not important here.
The above introduced standard "Sampling". "Over-Sampling" is when we sample higher than the condition set by Nyquist, and typically much higher for us to be concerned with the possible benefit of doing that.
The main thing that happens when we over-sample is the quantization noise from the conversion gets spread over a much wider frequency range, thus in most cases reducing the noise from quantization in our frequency band of interest and therefore acting as a converter with a higher number of bits! I have explained this further at this link so will refer to that for further detail on over-sampling:
What are advantages of having higher sampling rate of a signal?
An analog signal can be higher in frequency than the first Nyquist Zone and still be sampled as long as the analog bandwidths of the system (including the A/D converter itself) are wide enough to pass the signal. Such is the case in the graphic below copied for the link I first gave above that details this further. Here we are sampling a signal that is in the 3rd Nyquist Zone, and the resulting digital signal is indistinguishable from a similar signal that was in the 1st Nyquist Zone. So assuming a wide enough analog bandwidth, we can select any Nyquist zone to sample through the design of a anti-alias filter prior to the A/D converter. For standard and over-sampling conditions we would use a low-pass filter. And for under-sampling conditions we would use a band-pass filter. With no filter all the Nyquist zones would be sampled, thus we would have significant degradation due to noise and interference folding (aliasing). This is specifically the important reason to always have an anti-alias filter prior to the A/D converter! "IF-Sampling" and "Direct-Sampling" are implementations of under-sampling. IF-Sampling is when we sample the IF frequency in a super-heterodyne receiver architecture, and Direct-Sampling is when we have an A/D converter with a high enough input analog BW (or a low enough input RF signal) that we can sample the RF signal directly.
Over-sampling implies having many more samples than the highest frequency of interest, and under-sampling implies we are down-converting the bandwidth of interest with a higher harmonic of the sampling clock (effectively). Thus as given in the first link, we can simultaneously under-sample and over-sample such as the following example using GPS:
Consumer GPS approximately occupies 2 MHz of BW at a carrier of 1575.42 GHz. With an A/D converter that had an analog input bandwidth that exceeded this carrier frequency, we could directly sample the amplified and filtered signal from a GPS antenna with 100 MHz sampling rate (for example), which would result in a (spectrally inverted) copy of the GPS signal at 16* 100 MHz -1575.42 MHz = 24.58 MHz; well positioned for a digital IF in our 100 MHz sampling space. This would be digitally down-converted to baseband and then filtered where we would benefit from the advantages of over-sampling at 100 MHz the GPS signal that occupies significantly less bandwidth. Thus we under-sampled by down-coverting with the sampling process, and over-sampled by choosing a sampling rate much higher than the minimum necessary.