Is Seifert-van Kampen comparable to inclusion-exclusion?

My understanding of the Seifert-van Kampen theorem is that for two spaces U and V, pi_1(U \cup V) can be written as a free product of pi_1(U) and pi_1(V), modulo pi_1(U \cap V). Intuitively, the free product is the naive way of combining the fundamental groups of two spaces, but it leads to overcounting the loops, so we then rein in our guess by quotienting out the stuff we double counted.

This feels remarkably similar to the inclusion-exclusion theorem, that |A \cup B| = |A| + |B| - |A \cap B|. Or the similar theorem for vector spaces, that dim(U + V) = dim(U) + dim(V) - dim(U \cap V). Is my intuition that these are related correct? Is there some broader way of generalizing these notions?