The question conflates a number of different things.
- "How to deal with category mistakes and other ontological problems when teaching a concept?" (the example about failing to recognize a square as such)
- "How to spare a student's feelings when telling them they are wrong?" (the point about being sensitive)
- "What to do about students who falsely believe they are right?" (the point about insisting the square is peanut butter)
- "How to help students make fewer mistakes when applying techniques they learned?" (the realistic example of incorrect log transformation)
You have of course added information to try and make the question more clear, but I think it's nevertheless confused things a bit, and it's better to answer these separately. Taken on its own, each sub-question has a simple and direct answer, and when individually understood, these answers make the overall issue plainer to see.
Mistakes in applying techniques
The time-tested solution is practice, practice, practice. If students make mistakes with algebraic operations that they already "know", first thing you want to make sure is that they're getting adequate practice via homework, problem sessions and in-class example problems/solutions. When solving non-trivial problems, one must not only apply techniques correctly, but also be able to select which techniques are appropriate. You can supplement this with trivial problems, such as asking them to rewrite "a=logx" as "x=e^a" and vice versa, or evaluate with certain numeric values of x or a.
It is also useful to teach fall-back techniques when their knowledge of the primary skill fails. For example, even if they don't remember whether the distributive property applies to logs, they can try to prove/disprove it in some quick way (such as: "log2(16*4)=log2(64)=6" clearly does not equal "log2(16) * log2(4) = 4*2 = 8"). Another option when failing to remember a rule is to try and remember its derivation instead.
Sparing a student's feelings
There's a lot to be said here but briefly, you want to create an environment where students feel safe in making mistakes and asking questions, while also having confidence in their ability to learn. You should set up the lesson plan so that everyone is always learning something, even if not everything, in that lecture. When explaining concepts and answering questions, try to identify what part of the explanation seems like a "leap" to the student, and break it down into simpler steps. Recall earlier lectures where students were not able to solve a problem which they now can, and point out that what seems intractable now will soon become soluble with some effort and practice.
Keep in mind also that not everyone will be a prodigy in every subject. You want to present the subject as a ladder of knowledge and techniques, where student will see that increasing commitment of effort will yield increasing mastery, and yet there are evenly spaced "exit points" where they can stop investing into the subject and still have some partial mastery to take away from it. This also helps them recognize the proverbial steps by which mountains are climbed.
Dealing with stubborn students
Assuming the student is acting in good faith, the problem here is typically your failure to establish rapport and authority in the class. Ideally, you want to establish and maintain as clear a picture as possible in the students' minds of what they are attempting to learn in a class and what the utility of this is. Even if you are not able to justify to them what good logarithms are in every day life, you can at least emphasize that they are a prerequisite of many other interesting topics. You can also look for examples of real-world problems where they apply (exponential population growth is often a good one).
When the a student claims that you are wrong, you should be prepared to justify your claim with various proofs and examples, as well as refuting the student's claim persuasively. This of course requires a pre-agreed upon standard of truth: Either the student body must implicitly believe certain criteria for accepting an argument as correct, or you must establish them from the first day of class.
Note that students claiming you are wrong are an excellent opportunity to (a) figure out what parts of material you failed to explain adequately and (b) teach students techniques for independently verifying their own work and catching their own mistakes.
Category and other ontological mistakes
What I mean by this is things like confusing a square with a rectangle.
This is a broad pedagogical topic but ultimately you want to avoid relying too much on the Socratic method if your rapport with the students is not excellent. Do not draw a square, ask what it is, and then get frustrated when they say "a drawing". Tell them the rule right away:
In this class, we are mainly interested in whether things are squares, triangles and circles. If they have four equal sides we will call them squares. There will not be trick questions about equilateral parallelograms or non-Euclidean planes so don't worry about that.
As the class goes on and students learn your style, you can ramp up the Socratic element, but you should always start out didactically.
You want to pick a closely related set of learning objectives, ideally in the same or similar ontological categories, and focus on those. Leave the philosophy to philosophy class. When teaching algebraic techniques, don't distract them with difficult ontological dilemmas. It's okay (and arguably useful) to point out ontological asides, but don't quiz them on these.