1-Where is Andrew?
2-Do you know where Andrew is?
I think in the first statement it's (wh word and) object and second one might acting like preposition.
I am wondering why auxiliary verb and the name "Andrew" place has been changed.
English Language Learners Stack Exchange is a question and answer site for speakers of other languages learning English. It only takes a minute to sign up.Sign up to join this community
The word "where" has the same function in both sentences. In both cases, the word "where" stands in for an unknown or unspecified location. Grammatically, it is a pro-form, arguably a pro-adverb. It's often referred to as an "interrogative pronoun", but that term is misleading*, so let's just call it a "wh-word" for now.
If you use a wh-word followed by an inverted subject and auxiliary, that's the structure of a wh-question, like in sentence 1.
On the other hand, if you use a wh-word followed by subject and auxiliary in the normal order, that's the structure for a wh-clause, in this case representing a location, as in sentence 2. A wh-clause is a clause that represents information.
So in both sentences, "where" represents the unspecified information of Andrew's location. The difference is in the grammar structure, not the meaning or function of the word "where".
*It's misleading because "where" has functions other than interrogatives (questions), and while it is a pro-form, its antecedent is an adverbial or prepositional phrase, never a noun.
 Where is Andrew?
 Do you know [where Andrew is?]
So you're asking about the grammar.
There's no object in either of these. In both cases "where" is best analysed as a preposition ("in/at some place").
The answer to your question has to do with the contrast between main clause interrogatives and subordinate ones.
 is a main clause interrogative in which "where" is complement of "be" (It questions location, i.e."at what place"), and "Andrew" is subject. The declarative version would be "Andrew is at x place". Since "Andrew" is not subject, it's position at the front of the clause triggers subject-auxiliary inversion.
, by contrast, contains the bracketed subordinate interrogative clause (embedded question), where the meaning is: "Do you know the answer to the question 'Where is Andrew?'" Subordinate interrogatives do not normally have inversion.