I have a confusion about the concept of a direct product of a family of algebras in Universal algebra. I shall use the definition in Blackburn $\textit{et al}$ (2001) Modal Logic, p:498-9.
(A similar definition is found in https://en.wikipedia.org/wiki/Direct_product#Direct_product_in_universal_algebra)
Let $(\mathfrak{A}_j)_{j ∈ J}$ be a family of algebras. The product $\prod_{j \in J}\mathfrak{A}_j$ of this family is the algebra $\mathfrak{A} = (A, f_{\mathfrak{A}})_{f \in F}$, where the carrier set $A$ of $\mathfrak{A}$ is the cartesian product $\prod_{j \in J}A_j$ of the carriers $A_j$, and the operation $f_{\mathfrak{A}}$ is defined componentwise; that is, for elements $a_1,...,a_n \in \prod_{j \in J}A_j$, $f_{\mathfrak{A}}(a_1,...,a_n)$ is the element of $\prod_{j \in J}A_j$ given by:
$$f_{\mathfrak{A}}(a_1,...,a_n)(j) = f_{\mathfrak{A}_j}(a_1(j),...,a_n(j))$$
Suppose we have $(a_1,...,a_n)$, and a given algebra $\mathfrak{A}_i$ in our family of algebras $(\mathfrak{A}_j)_{j ∈ J}$. Then we should have an operation:
$$f_{\mathfrak{A}}(a_1,...,a_n)(i) = f_{\mathfrak{A}_i}(a_1(i),...,a_n(i))$$
But what exactly is denoted by $a_1(i)$, etc, in this case? How can we presume that $a_1(i)$ actually belongs to the algebra $\mathfrak{A}_i$, especially given that we have no guarantee that the $a_i$ in $(a_1,...,a_n)$ belong to $\mathfrak{A}_i$, given that the $a_i$ consist of elements of different carrier sets? Doesn't the definition of $f_{\mathfrak{A}}$ implicitly presume that the $(a_1(i),...,a_n(i)$ belong to $\mathfrak{A}_i$? I don't understand why to accept this should be the case.
I would be helpful if someone could clear up my elementary confusion. Perhaps a simple toy example would help.
This notation is indeed a bit weird. What happens here is that $a_i$ is an element of $\prod_{j\in J}A_j$; this can be interpreted as a function $a_i: J\to \cup_{j\in J}A_j$ such that $a_i(j)\in A_j$ for all $j\in J$, so you can think of $a_i(j)$ as the $j$-component of $a_i$ in the product.
For a simple example, take $J=\{1,2\}$. Then giving a family of algebras $(\mathfrak{A}_j)_{j\in J}$ is the same as giving two algebras $\mathfrak{A}_1,\mathfrak{A}_2$. The product $\prod_{j\in J}A_j$ is the set of function $a:\{1,2\}\to A_1 \cup A_2$ such that $a(1)\in A_1$ and $a(2)\in A_2$. Thus giving such an $a$ is the same as giving a couple $(a(1),a(2))$ in the usual cartesian product $A_1\times A_2$.
Now you can see in that case what it means for the operations to be defined componentwise. If you have an $n$-ary operation $f\in F$ and elements $a_1,\dots,a_n\in A_1\times A_2$, you can write $a_i=(a_i(1),a_i(2))\in A_1\times A_2$ for every $1\leq i\leq n$. Now saying that $$f_{\mathfrak{A}_1\times \mathfrak{A}_2}(a_1,\dots,a_n)(1)=f_{\mathfrak{A}_1}(a_1(1),\dots,a_n(1))$$ and $$f_{\mathfrak{A}_1\times \mathfrak{A}_2}(a_1,\dots,a_n)(2)=f_{\mathfrak{A}_1}(a_1(2),\dots,a_n(2))$$ simply means that \begin{align}f_{\mathfrak{A}_1\times \mathfrak{A}_2}(a_1,\dots,a_n) & = f_{\mathfrak{A}_1\times \mathfrak{A}_2}((a_1(1),a_1(2)), \dots , (a_n(1),a_n(2)))\\ & = \left(f_{\mathfrak{A}_1}(a_1(1),\dots,a_n(1)),f_{\mathfrak{A}_2}(a_1(2),\dots,a_n(2)) \right),\end{align} i.e. the operations are performed separately in each component of the product.