Direct sums and products in topological groups and vector spaces