1. David: I have to talk to you about something. (original statement)
2. David said "he had to talk to me about something". (indirect speech)
3. he had to talk to me about something. (Independent sentence)
If we take the quoted part of the sentence no. 2 with sentence no. 3 that shows these two sentence are same as per grammatical structure but meaningfully different. and sentence no.2 is meaningfully same with sentence no.1 even if these are different at grammatical structure. could anyone explain?
I don't understand your question.
In 2, we do NOT use the quotation marks to show indirect speech. #2 is an indepdendent sentence with indirect speech in it. With indirect speech, we stay as close to the original speech as possible, shifting tense somtimesa and other things like time or place markers.
In 3, you need a capital letter at the start of the sentence. It's an overall description of what he wanted
Peter said, "It's absolutely imperative that you come see me before you talk to John." - Direct quote
Peter said that it was absolutely imperative that I go see him before I talked to John. - Indiret quote
Peter stressed how important it was I talked to him before John. - Narrative of the statement.
I'm not a teacher, but I write for a living. Please don't ask me about 2nd conditionals, but I'm a safe bet for what reads well in (American) English.