You are incorrect about the domain of $$\frac{1}{\quad\frac{1}{\cos x}\quad}.$$
Recall that when we describe a function, we are supposed to give the domain and the value at every point of the domain. We have a convention that, for real-valued functions of real variable, if we describe a function by giving a formula and we do not explicitly state the domain, then the domain is “all numbers for which the formula, as written, makes sense.” This is called the “natural domain of the function.”
The function
$$f(x) = \frac{1}{\quad\frac{1}{\cos x}\quad}$$
is given just by a formula. So the domain is “all $x$ for which the formula, as written, makes sense”.
The $\cos(x)$ part always makes sense. The reciprocal only makes sense when $\cos(x)\neq 0$, so we must exclude all $x$ at which $\cos(x)=0$; this is all $x$ of the form $x=\frac{\pi}{2}+2\pi n$, with $n\in\mathbb{Z}$, or of the form $\frac{3\pi}{2}+2\pi n$, with $n\in\mathbb{Z}$. These two amount to all reals except those of the form $\frac{\pi}{2}+k\pi$, $k\in\mathbb{Z}$. Then the reciprocal of that will make sense provided $\frac{1}{\cos(x)}\neq 0$. As this always happens, that is all.
So the natural domain of $f(x)$ is all $x\in\mathbb{R}$ except for those reals of the form $\frac{\pi}{2}+k\pi$, $k\in\mathbb{Z}$... exactly the same domain as the function $g(x)=\frac{1}{\sec x}$. So the two are in fact the same function, as they have the same domain and always take the same values.
By contrast, consider $\tan(x) = \frac{\sin x}{\cos x}$, $\cot(x) = \frac{\cos x}{\sin x}$. If we let $f(x) = \frac{1}{\cot x}$, is this function equal to $\tan (x)$?
No! Because $\tan(x)$ is defined at all points where $\cos(x)\neq 0$, which means all $x$ except those of the form $\frac{\pi}{2}+k\pi$, $k\in\mathbb{Z}$ (like the previous function).
The domain of $f(x)$ is all $x$, except those for which either $\cot(x)$ is undefined, or those in which $\cot(x)=0$. This means both all points of the form $\frac{\pi}{2}+k\pi$, $k\in\mathbb{Z}$ (points where $\cot(x)=0$), and all points of the form $n\pi$, $n\in\mathbb{Z}$ (where $\cot(x)$ is undefined). So we get that the function $f(x)=\frac{1}{\cot(x)}$ has domain all real numbers except those of the form $\frac{k\pi}{2}$, $k\in\mathbb{Z}$, whereas $\tan(x)$ is defined at all $x$ except those of the form $\frac{\pi}{2}+m\pi$, $m\in\mathbb{Z}$.
The moral here is that to find the natural domain of a function you do not simplify, as that may change the domain of the function.