Sum and multiplication on graded algebras Let $A$ be an algebra over a field $\mathbb{K}$ and $G$ a commutative group under addition. This algebra is called a $G$-graded if there exists a family $\{A_{g}\}_{g\in G}$ of vector subspaces of $\mathcal{A}$ such that:
$$\mathcal{A} = \bigoplus_{g\in G}A_{g}$$
and $A_{g}A_{h} \subseteq A_{g+h}$.
Question: The above definition is the usual definition of a $G$-graded algebra. But the direct sum in the right hand side of the equality must be an algebra too. What are the operations (sum, multiplication and scalar multiplication) defined in such direct sum? Are these operations always defined to be the natural ones? By the natural ones I mean that, if $a = (a_{g})_{g\in G}, b = (b_{g})_{g\in G}$ and $\lambda \in \mathbb{K}$:
$$a+b := (a_{g}+b_{g})_{g\in G} \quad ab := \sum_{g,h\in G}a_{g}b_{h} \quad \mbox{and} \quad \lambda a := (\lambda a_{g})_{g\in G}$$
 A: 
But the direct sum in the right hand side of the equality must be an algebra too.

The operations are the ones defined by the algebra structure; the equality with the direct sum is just a $k$-vector space equality. The direct sum of rngs can be nonunital for inifnite indices, however there are unital graded algebras with inifnitely many non-trivial homogenous components (those are concrete examples in which we definitely cannot have an equality as algebras). For example, the ring $k[x]$ has a $\mathbb Z$-grading induced by the degree of a polynomial.
From the comments:

Btw, each $a_g$ and $b_g$ are elements of vector spaces of $A$, so these vector spaces inherite the operations of.

Well, we know how to multiply them according to the algebra structure on $A$, but their product lies on $A_{g^2}$ which is never $A_g$ unless $g = 1$. Hence multiplication cannot be defined "component wise" on each subspace.
However, if you know the homogeneous components of two elements and how multiplication works between homogeneous elements, you can recover the operations. Namely, if $a = \sum_{g \in G} a_g$ and $b = \sum_{h \in G} b_h$ (and by usual abuse of notation all but finitely many elements of each sum are zero) then
$$
a+b = \sum_{g \in G} a_g + b_g, \text{ so }(a+b)_g = a_g+b_g;
$$
$$
\lambda \cdot a = \sum_{g \in G} \lambda a_g, \text{ so } (\lambda a)_g = \lambda \cdot a_g,
$$
and
$$
ab = \sum_{g,h \in G} a_g b_h = \sum_{g \in G} \sum_{s \in G} a_s a_{s^{-1}g}, \quad (ab)_g = \sum_{s \in G}a_sb_{s^{-1}g}. 
$$
