In terms of grammar, let’s look at the difference between active and passive sentences. (The following basically only applies to transitive sentences - those that involve one entity performing an act upon another. It’s only a rough overview. I tried to explicitly explain the very basic grammar because I know a lot of people never hear about subjects and objects and stuff in English class; apologies to those that already know this stuff. I’m not trying to be patronizing to those who already know most of this.)
Take an active sentence like this: Maria slapped John. Maria is, in syntactic terms, the subject of the sentence. Subjects generally appear before verbs, and verbs agree with the subject of a sentence (so you have He is tall, but They are tall - the verb takes a different form depending on whether the subject - he or they in this case - is singular or plural.) Now, in most ordinary active voice sentences, the subject is also semantically (that is, in terms of the sentence’s meaning) the agent of the sentence. An agent is an entity that performs an action. One test to see if something is a subject of a sentence is whether it can be replaced with a subject pronoun. The following are the subject pronouns of English: I, you, he, she, it, we, they.
John is the direct object of the sentence. The direct object usually appears after the verb; if you replace it with a pronoun, you use an object pronoun: me, you, him, her, it, us, them. (Notice that some pronouns are the same for both subject and object.) Direct object, again, is a term that has to do with the sentence’s syntax. In terms of the sentence’s meaning, John is the patient - that is, the entity upon which the action is performed.
So in an active voice sentence, usually the subject is also the agent - the subject is the thing that performs the action. And the direct object is the patient - it’s the thing that the action is done to. Passive sentences work differently.
In a passive sentence, the patient is raised to the subject position. So the passive equivalent to the above is John was slapped (by Maria). (I’m using parentheses to note that that part is optional.) The patient, the entity that (in this case) gets slapped is the subject. Note that when you use pronouns, the sentence becomes He was slapped (by her). John is replaced by he, a subject pronoun, which signals that John is now the subject of the sentence. Maria, in turn, doesn’t have to show up in the sentence at all. In a passive sentence, you have the option of omitting the agent entirely; if it appears, it is an object of a preposition, the preposition being by.
So in an active sentence, the subject of the sentence is the agent (the performer of the action) while the object is the patient (the one the action is performed on.) In a passive sentence, the subject is the patient, and there is no direct object. The agent, if it’s included at all, is in a prepositional phrase and it’s introduced by by.
The verb changes too; it’s replaced by a form of be plus a past participle (in this case, slapped.) So Maria ate the chocolates becomes The chocolates were eaten by Maria. There’s a form of be, in this case were, plus a past participle. (Notice that past participles are often, but not always, the same as the past tense form of the verb.)
There’s no single, simple rule to identify a passive sentence. But look for a form of be plus a past participle. If the sentence includes by so-and-so, or if you could mentally add it to the sentence, and that so-and-so is the entity that performs the action, it’s probably a passive sentence.
Oh, and Scissorjack’s advice about when you can use the passive voice is right on. The passive voice can certainly be overused, but it’s not the evil that a lot of style guides pretend; there’s definitely a place for it in all sorts of writing. It’s a good idea not to use the passive voice too much, but that’s one of those rules that tends to be repeated a lot more than it deserves; there’s nothing wrong with using it occasionally.