Did you have a mentor there? Someone who could help give you feedback about it?

Look for that in your next role. It helped me tremendously.

Obviously, I don't know the specifics, but the way you speak about it sounds like you were unable to empathize with the person in question, and that means there were considerations you were not privy to, that made it so your being assertive had you coming across as obnoxious rather than helpful.

It has to start there, with you empathizing with them. No one makes decisions in a vacuum. Unless you believe them to be legitimately insane, they have a reason. It might be one you disagree with, or is ethically dubious, or cowardly, or similar, but understanding it, and the misunderstanding, fear, etc, that underpins it, is key to being able to show them that you respect their concerns and views.

Here's a personal example; I worked for a place where the VP in charge of our department was given the choice of "here's 8 million dollars to engage this ludicrously expensive consulting company, that has execs playing golf with our own execs, or, you can instead try and build a team from scratch, which you've not done, and have them build the product instead". As you might expect, he chose the former. Though, he also had a mandate to start building a team for other reasons anyway, and I was part of that, and we started by looking at what the consulting company was building, as we would inherit it. And it was crap. Complete crap.

Now, we didn't know he had this terrible choice at the beginning. We didn't know any of the pressures or expectations he was under. All we saw was that the super pricy consultants were delivering crap. And we expressed that.

What did he do? He was in a no win situation, and so chose to bury his head in the sand, ignore what we were saying, but get angry at how aggressively we were saying it.

Now, admittedly, that's a cowardly response. But in hindsight I can see how easy it would be to feel powerless in that situation, despite being a VP. I dropped the ball in handling that; had I understood his considerations better, and pitched myself as trying to solve his problems, rather than my own (my problems being we were inheriting this bucket of crap, his problems being that he felt he HAD to deliver, and this was the only way that was even remotely possible), I likely could have made better headway (by offering solutions with tradeoffs, yes, we can't have this in the defined timeline, but we can instead do ~this~, and that will minimize the visibility of the problems while giving us time to fix things, etc).

I got better at handling that kind of situation because I was lucky to have a couple of friends, one of whom was above me, and one who was a peer, also dealing with the same situation (and plenty more to follow over the next few years); we could discuss the situations and better figure out our mistakes.

To saying something offensive; when you found that out, did you immediately go to the CTO and apologize? I've had that happen too, multiple times, where someone (not even in my hierarchy) took offense at something I said. As soon as I found out I immediately went to them and apologized (arguably a non-apology even; a "Hey, I heard something I said bothered you. I'm sorry about that; I'm not sure what I said, but my intention was never to offend you. Please, in future, let me know ASAP so I can better learn to recognize it when it happens and hopefully keep it from happening again"); in both cases it turned that person into an ally for me, as they recognized that even if I was aggressive or (inadvertently) offensive, I still valued them.