If Ai is an indexed set of objects in a category, its product is an object C, along with projection morphisms pi taking C to each Ai. Furthermore, for every object B, and collection of morphisms fi from B into Ai, there is a unique morphism f from B to C such that pi(f) = fi. In other words, there is some f so that each triangle commutes, taking B to Ai directly via fi or indirectly via f followed by pi.
If the category is concrete, and the index is finite, the product is simply the cartesian product, with the usual component projections. You need to verify that f is a morphism in the category, but this is usually the case. For instance, if each fi is a group homomorphism, then the direct product is a group, and f is also a group homomorphism.
If we accept the axiom of choice, the indexing set may have any cardinality. This admits infinite direct products, e.g. the product of infinitely many copies of the group Z.
The product of topological spaces is also valid, assuming we use the weak product topology. In fact, that is the default topology, so that the product of spaces becomes a product in the categorical sense.
Injections pi carry each Ai into C, and for every B and family of morphisms fi from Ai to B, we have a unique morphism f from C to B such that fi = pif. We can go straight from Ai over to B, via fi, or we can inject Ai into C via pi, and then apply f. The triangle commutes.
A proof, similar to the one given above, shows that the coproduct is unique up to equivalence.
If injections remain morphisms through a permutation function S, then the order of the component objects is not significant.
In the category of sets, the coproduct is the disjoint union. The projection pi maps Ai into a copy of itself in C. Let f map this copy of Ai into B just as fi maps Ai into B. This definition holds for each i, hence f is defined on all of C. And if f is defined any other way, on any point, one of the triangles will not commute; hence the morphism is unique. This makes C the coproduct.
In most concrete categories, the image of the identity element, under any morphism, is forced, hence there is no contradiction if pi maps the identity element of each Ai to the identity element of C. In other words, the injections of the components are not strictly disjoint; they share a common element, namely the identity element of C. If you are familiar with groups and modules, then you know that these structures are called disjoint if they have nothing in common except for the identity element. This is somewhat confusing, and a new word would have been preferable, but that's not how math evolved. At any rate, C is the smallest structure that contains disjoint components Ai.
In the category of abelian groups, rings, or R modules, the coproduct of finitely many components is the same as the product. Let the components be disjoint (other than the common identity element), and C is the span of these components, which is the direct product. Each component maps into C by setting all the other components to the identity element. Verify that this injection is a morphism. Given functions fi from the components into another object B, build f so that the triangles commute. Although f has only been defined on the components of C in isolation, The morphism rules define f across the rest of C. That is why f is unique.
The coproduct of infinitely many rings or R modules is the direct sum. When f is defined on all the components, it is implied on the sums of finitely many components, and when C is the direct sum, that is all of C.
In the category of groups, the product may not be the coproduct. consider Z and Z, with a product of Z2. Can Z2 be the coproduct? Let B be a group containing x and y, such that x and y do not commute. Map 1 (in the first component) to x and map 1 (in the second component) to y. This means f(1,0) = x and f(0,1) = y. However, f(1,1) forces xy = yx, which is a contradiction. Thus Z2 is not the coproduct. There is a coproduct however, namely the free group on two generators. Map 1, in A1 and A2 respectively, to these two generators.
Let a group G be generated by a set of subgroups. This is an internal direct product iff subgroups commute with each other, and are independent. By independent we mean a subgroup must not intersect the group generated by the remaining subgroups, except for the identity element. This is clear when G is known to be a direct product. Conversely, if the subgroups commute, and are independent, we can show that G, i.e. the span of these subgroups, is isomorphic to their direct product. Independence assures us that different combinations of component values will not lead to the same element in G.
If subgroups are normal and disjoint, they commute. If x is in H1 and y is in H2, xy/x/y is in both H1 and H2 by normality, and H1 and H2 intersect in the identity element, so x and y commute.
Showing that subgroups or submodules are independent can be a dificult task. In the category of vector spaces, or modules over a pid, we can sometimes use a dimensionality argument.
In the case of finite groups, it is enough to show that the components commute, and their orders are pairwise coprime. Any two subgroups have no intersection, else the order of the common element would divide the order of both subgroups. Combine subgroups in a direct product, and its order remains coprime to any subgroup outside this product. Thus every subgroup is disjoint from the product of the others.