The tube lemma is as follows:
Let $X$ and $Y$ be topological spaces. Let $Y$ be compact. Let $x \in X$. If $N$ is an open set in $X \times Y$ such that $x \times Y \subset N$, then there is an open set $W$ in $X$ such that $x \in W$ and $W \times Y \subset N$.
This is Lemma 26.8 in Topology by James R. Munkres, 2nd edition. I think I'm clear about it and its proof.
Now how (to use the above result ) to derive the following?
Let $X$ and $Y$ be topological spaces. Let $A$ and $B$ be subspaces of $X$ and $Y$, respectively; let $N$ be an open set in $X \times Y$ such that $A \times B \subset N$. Suppose that $A$ and $B$ are compact. Then there exist open sets $U$ and $V$ in $X$ and $Y$, respectively such that $$A \times B \subset U \times V \subset N.$$
My effort:
(Based upon the valuable feedback from @GregoryGrant. )
Fix an $a \in A$.
Then, for each $b \in B$, there exists an open set $U_{a, b}$ in $X$ and there exists an open set $V_{a,b}$ in $Y$ such that $$a \times b \in U_{a, b} \times V_{a, b} \subset N. \tag{0} $$
In this way, we obtain a covering $\left\{ \ V_{a, b} \ \colon\ b \in B\ \right\}$ of $B$ by sets open in $Y$. Since $B$ is compact, there are finitely many of these sets, say, $V_{a, b_1}, \ldots, V_{a, b_n}$ such that $$B \subset \bigcup_{j=1}^n V_{a, b_j}. \tag{1} $$
Let us put $$V_a \colon= \bigcup_{j=1}^n V_{a, b_j} \tag{2} $$ and $$U_a \colon= \bigcap_{j=1}^n U_{a, b_j}. \tag{3} $$
Then $U_a$ is open in $X$, $V_a$ is open in $Y$, $a \in U_a$, and $B \subset V_a$. Hence $$ a \times B \subset U_a \times V_a. \tag{4} $$
Moreover, if $x \times y \in U_a \times V_a$, then $x \in U_a$ and $y \in V_a$; so $x \in U_{a, b_j}$ for each $j = 1, \ldots, n$ [Refer to (3) above.] and $y \in V_{a, b_k}$ for some $k = 1, \ldots, n$ [Refer to (2) above.]; thus $x \times y \in U_{a, b_k} \times V_{a, b_k}$. But by virtue of (0) above $$U_{a, b_k} \times V_{a, b_k} \subset N.$$ So $x \times y \in N$. Hence we have shown that $$ U_a \times V_a \subset N. \tag{5} $$
Therefore, by (4) and (5) we can conclude that, for each element $a \in A$, we have a basis element $U_a \times V_a$ for the product topology on $X \times Y$ such that $$a \times B \subset U_a \times V_a \subset N. \tag{6} $$
Now $\left\{\ U_a \ \colon \ a \in A \ \right\}$ is a covering of $A$ by sets open in $X$; so there are finitely many of them to cover $A$; that is, there are finitely many sets, say, $U_{a_1}, \ldots, U_{a_m}$ open in $X$ such that $$A \subset \bigcup_{i=1}^m U_{a_i}. \tag{7} $$
Let's take $$U \colon= \bigcup_{i-1}^m U_{a_i} \tag{8} $$ and $$V \colon= \bigcap_{i=1}^m V_{a_i}. \tag{9} $$ Then the set $U$ is open in $X$ and the set $V$ is open in $Y$.
Now we show that $U \times V \subset N$. Let $x \times y \in U \times V$. Then $x \in U$ and $y \in V$. So $x \in U_{a_r}$ for some $r = 1, \ldots, m$ [Refer to (8) above.] and $y \in V_{a_i}$ for each $i = 1, \ldots, m$ [Refer to (9) above.]. Thus, $x \times y \in U_{a_r} \times V_{a_r}$. But by virtue of (6) above $$ U_{a_r} \times V_{a_r} \subset N. $$ So $x \times y \in N$, showing that $U \times V \subset N$.
Now we show that $A \times B \subset U \times V$. If $a \times b \in A \times B$, then $a \in A$ and $b \in B$. So $a \in U_{a_s}$ for some $s = 1, \ldots, m$ [Refer to (7) above.] and $b \in V_{a_i}$ for each $i = 1, \ldots, m$ [Refer to (6) and (9) above.]. Thus [Refer to (8) and (9) above.] $a \in U$ and $b \in V$. So $a \times b \in U \times V$ and thus $A \times B \subset U\times V$, as required.
From the preceding two paragraphs we have obtained $$ A \times B \subset U \times V \subset N. $$ Moreover, $U$ is open in $X$ and $V$ is open in $Y$.
Is this proof correct now?
My initial attempt:
For any $a \in A$ and for any $b \in B$, we have $a \times B \subset N$ and $A \times b \subset N$.
Since $a \times b \in N$, there is an open set $U_a$ in $X$ and an open set $V_b$ in $Y$ such that $a \times b \in U_a \times V_b \subset N$.
Now $\{U_a \colon a \in A \}$ is a covering of $A$ by sets open in $X$. So there are finitely many points $a_1, \ldots, a_m$ such that $$A \subset \cup_{i=1}^m U_{a_i}.$$
Similarly, $\{V_b \colon b \in B \}$ is a covering of $B$ by sets open in $Y$, and since $B$ is compact, therefore there are finitely many points $b_1, \ldots, b_n$ such that $$B \subset \cup_{j=1}^n V_{b_j}.$$
Can we take $$U \colon= \cup_{i=1}^m U_{a_i} \ \ \ \mbox{ and } \ \ \ V \colon= \cup_{j=1}^n V_{b_j}?$$
It's cleaner to split the proof into a new tube lemma and the actual proof, where both re-use the same proof idea as Munkres' Tube lemma formulation.
Extend the tube lemma first: Let $X,Y$ be any spaces. If $x \in X$ and $B \subseteq Y$ is compact and $\{x\} \times B \subseteq N$, where $N$ is open in $X \times Y$, then there are open sets $O_x \subseteq X$ containing $x$ and $O_B \subseteq Y$ open with $B \subseteq O_B$, such that $O_x \times O_B \subseteq N$. I'll call this the "real" tube lemma. If you study the proof in Munkres, this is what he actually showed there. (Note that it's a bit stronger as we can take $B= Y$ if $Y$ is compact, to get his version.)
Proof: just follow the proof in Munkres: For every $b \in B$ pick $U_b \subseteq X$ open containing $x$ and $V_b \subseteq Y$ containing $b$ such that $U_b \times V_b \subseteq N$. Finitely many $V_{b_1}, \ldots V_{b_m}$ also cover $B$ by compactness, and then define $O_B = \cup_{i=1}^n V_{b_i}$ and $O_x = \cap_{i=1}^n U_{b_i}$. Then just as in Munkres proof $O_x \times O_B \subseteq N$ ($(p,q) \in O_x \times O_B$ implies $q \in V_{b_j}$ for some $j$ and then $p \in U_{b_j}$ as well, and $(p,q) \in U_{b_j} \times V_{b_j} \subseteq N$ by their definition.)
Now to prove the original statement:
So we have $A \times B \subseteq N$. For every $a \in A$ we apply the "real" tube lemma above to $\{a\}$ and $B$, to find $O_a$ open containing $a$ and $O_B(a)$ containing $B$ such that $O_a \times O_B(a) \subseteq N$. Then again, finitely many $O_a$ cover $A$ by compactness of $A$, say $O_{a_1}, \ldots O_{a_n}$, and then define (following the same idea again) $U := \cup_{i=1}^n O_{a_i}$ which is open and contains $A$ (as they form a subcover) and $V = \cap_{i=1}^n O_B(a_i)$ which is an open neighbourhood of $B$ by finiteness. Now $U \times V \subseteq N$: if $(p,q) \in U \times V$, then $p \in O_{a_j}$ for some $j \in \{1,\ldots n \}$ and then $q \in V \subseteq O_B(a_j)$ and again $(p,q) \in O_{a_j} \times O_B(a_j) \subseteq N$ as required.
This proof set-up is exactly like the proof that in Hausdorff spaces are we can separate two disjoint compact sets by open sets, where we use a lemma to separate $x$ and a disjoint compact set $B$ first, and then prove the full result using the same idea. It's slightly easier on the notation I think.