Using secondary chords is akin to a making a brief, temporary key change. The starting point for the analysis is not the secondary chord itself, but rather its target: one of the standard diatonic chords in the primary key.
There are 7 diatonic chords, but only five can support secondary chords. The tonic cannot because we are already in its key, so there can be no temporary key change. The vii chord in a major key and ii chord in a minor key cannot because they are diminished chords, and a diminished chord cannot be the tonic of any key (keys are only major or minor).
For any of the remaining five chords, a secondary chord works by treating the chord as the tonic of a new key. For example, in the key C major, the ii chord is Dm. Before playing the Dm chord in a progression, we can add certain chords from the key in which Dm is the tonic — that is, the key of D minor — like the V chord from D minor, A. This emphasizes the Dm, provides greater pull towards it in the progression, and add an interesting variation in sound.
There are a few types of secondary chords, but all of them are based on the “dominant” harmonic function.
The V chord in a key is known as the dominant, and it creates a strong pull towards resolving to the tonic. That pull is even stronger with a dominant seventh chord, V7, but it can also just be the major triad without the added seventh. Although the natural minor scale
A dominant chord A secondary dominant is the V chord of the key in which the target chord is the tonic. For example, in the key of C major, the G chord is the V chord of the primary key. Before playing a Dm, you can play the V chord from the key of D minor — an A chord — which had the effect of taking the V – i relationship from the key of D minor and