No, dogs do not have to be the same breed in order to mate and produce offspring. Pairings between different breeds result in hybrid offspring, also known as mixed breeds or mongrels.
While purebred dogs are bred within the same breed to maintain specific characteristics and lineage, mixed-breed dogs can result from pairings between different breeds or mixed-breed lineages.