There are two typical topological ideas being used here.
The first is the idea of "localizing" at a point $P$ and performing a calculation $f(U)$ that involves an open neighborhood $U$ of $P$ that is independent of the choice of neighborhood. You can reduce the case of showing $f(U) = f(V)$ to the case of $V \subseteq U$, by the argument $f(U) = f(U \cap V) = f(V)$.
The second idea is that when you have a basis for a topology, you can typically rephrase any idea using open sets into one using the basis sets, because every open set is a union of basis sets.
The sets $D(f)$ (the complements of $Z(f)$) are a basis for the topology of an affine scheme.
$U$ and $V$ both contain a basis set $D(f)$ and $D(g)$, and the their intersection $D(fg)$ is a basis set contained in $U \cap V$. Therefore
$ T_p U \cong T_p D(fg) \cong T_p V.$
Incidentally, you really want to show a stronger claim: that the isomorphisms involved are 'coherent': e.g. that if you have a chain of inclusions $W \subseteq V \subseteq U$, that the isomorphisms
$ T_p U \cong T_p V \cong T_p W $
gives the same isomorphism as $T_p U \cong T_p W$ from invoking the theorem directly on $U$ and $W$. More precisely, you want to construct a functor between categories:
Open neighborhoods of p and inclusions --> Vector spaces and isomorphisms
If such a functor didn't exist, then even while the tangent space is well-defined as an abstract group, it would be rather difficult to actually use due to subtle technical issues.