A secondary dominant temporarily tonicizes the chord it follows. For the briefest of moments, we hear some chord that is not the tonic and because a dominant-sounding chord came before it we think it's the tonic anyway.
For example, let's say you and three of your music theory colleagues are singing Mozart's Jubilate Deo. The piece is in G. G is the tonic. But at the end of the series of "in laetitia"s, with that beautiful polyphonic texture resolving into homophony, all voices rest on a D chord, which would normally be the dominant of the piece and would be notated with a capital V in roman numeral analysis.
The chord before that chord is an A major chord. Notably, there's an accidental in this chord - a C sharp is not normal in the key of G. That's because once we "tonicize" the D chord that follows, the C sharp is the leading tone that points to D, which is why the D sounds like the tonic in the first place.
So how do we analyze this? Jubilate Deo is in G. This chord with an accidental in it that points to a tonicized D... it's an A major chord. Do we call it a capital II and say it's quittin' time? NO! Because we don't hear it as a capital II chord; we hear it as a dominant chord, and protip: dominant chords are always V-chords. So since D is the fifth of what the actual tonic is (that is to say, G), we notate this A-chord as the fifth of D, or V of V. Notation minutiae vary (some folks will kick you out of their theory parties unless you use an arrow to point from one V chord to the next, while others likewise will kick you out of the theory party for not calling the applied dominant "V/V").
Applied dominants can be used in composition to help orient the listener to where a piece is going. It also just plain spices up a piece. Diatonic sets are wonderful and they keep a listener's mind uncluttered and less confused, but a well-placed accidental for a good reason (like an accidental as a leading tone to a chord within the diatonic set) makes a piece more vivid.