secx = 1/cosx = cos^-1x = arccos

1/cos(x) is not the same as cos^(-1)(x).  The superscript -1 denotes an inverse function and to my understanding is usually reserved in trig for this specific reason.
Ah, the famous proof by ambiguous notation.

What's wrong about that is you using the notation cos^(-1) to mean two different things at the same time.

First you use cos^(-1) to denote the recipricoal of cosine, and then in the very next step you use it to denote the invrese of cosine.

Those two things are not the same, so decide how are you going to use the notation cos^(-1), and stick with that meaning within a single text you're writning.
Other people have correctly pointed out that sin^(-1)(x) and cos^(-1)(x) do not typically denote their reciprocals, but their functional inverses.

I want to highlight that your error is completely reasonable and the common convention around indices and trig notation is a complete mess. While -1 isn’t used to indicate the reciprocal (what it would mean for a number), whole numbers do represent the typical power indication. That is, we usually write

> sin^(2)(x) := (sin(x))^2

rather than the functional equivalent of -1 indicating the functional inverse, which would be:

> sin^(2)(x) := sin(sin(x)).

Quite often, particularly for more abstract courses in analysis or topology, you will absolutely see this notation get used for general functions (where f^(n)(x) represents the composition of f, n times, acting on x).

The fact that trigonometric functions walk the line of using indices to denote both meanings is, frankly, stupid. It’s unreasonably cruel convention borne out of historic usage without any concern for new students. I’d encourage you to stick to arcsin(x) and cosec(x) rather than ever having to use sin^(-1)(x); it’s just less ambiguous.
cos(x) = y

x = cos^(-1)(y)

sec(x) = 1/cos(x)

secx and arccos are not the same
cos is a function
cos(x) is a number
cos^(-1) denotes the inverse of a function, i.e. arccos
cos^(-1)(x) is a real number: the function cos^(-1) (or arccos) evaluated at the input x
cos(x)^(-1) is a real number: the multiplicative inverse (or reciprocal) of the number cos(x)

so cos^(-1)(x) and cos(x)^(-1) are different things because the "^(-1)" part is being applied to a different type of object. in cos^(-1)(x), the ^(-1) is being applied to the function cos, and in cos(x)^(-1) it is being applied to the number cos(x).
cos^-1(x) means inverse function of cos(x), not inverse of cos(x).
The problem is that both this notation tends to get used in an ambiguous fashion *and* it depends on just what you are taking the inverse of.

This is unfortunately, not explained too well, but there is a *difference* between "cos" and "cos(x)", even though that often times they get slopped together. "cos" is a *function*: it is a mathematical object of a different "type" from a number. "cos(x)" is a *number*: it is the number that is generated by applying cos to the number "x". The specific individual number may be unknown or undetermined at this time if we have not bound "x" to a value, but it is still a number.

When dealing with functions, functions don't, "by default", "multiply", they *compose.* When a function is exponentiated, viz. f\^n, it means it gets composed with itself n times, viz. f\^2(x) = (f o f)(x) = f(f(x)). When the exponent is negative, that means it has to be anti-composed, which means taking the inverse function.

When you take 1/$cos(x)$, you are taking the reciprocal of a number. Note the bracketing. The whole thing "cos(x)" goes into the division. This is, of course, sec(x). When you take "cos\^-1(x)" - note where the "\^-1" part is. It's on cos - "cos" is *a function*. Thus it generates the function inverse. Were it "$cos(x)$\^-1" instead, then now "\^-1" is acting on *a number*, and thus this is equal to *the number* "sec(x)" (*not* "sec", i.e. writing "$cos(x)$\^-1 = sec" is nonsense or, at least, false.).

Of course, all this is unfortunately thrown off for trig functions by the fact that historical cruft causes people to most commonly understand something like "cos\^2(x)" as meaning "$cos(x)$\^2" and not, as consistency should have it, "$cos o cos$(x)" i.e. "cos(cos(x))". Yes, that's super inconsistent. If you want, you can always put a small circle, of the same appearance as a composition infix symbol, before the exponent to indicate explicitly that compositional power is intended, viz. "cos\^o2(x)" means "cos(cos(x))" unambiguously, and "cos\^o-1(x)" means "arccos(x)".