What is subject of the second sentence joined by "and"? [duplicate]

A compound sentence involves at least two independent clauses united by a conjunction, that is, if you were to read only one clause it would stand alone.

We sang and we danced. ("We sang" and "We danced" are independent clauses.)

We sang, but others danced. ("We sang" and "Others danced" are independent clauses.)

We sang so others could dance. ("We sang" and "Others could dance" are independent clauses.)

A compound predicate means that a subject has two predicates united by a conjunction . That's what your example is:

We sang and danced

"Danced" is not an independent clause but pertains to the same subject in a single independent clause. Using the compound predicate allows one to avoid having to repeat the subject:

We sang. We danced. (Repeats subject in two successive sentences.)

We sang and we danced. (Repeats subject in two successive independent clauses.)

We sang and danced. (Two successive predicates pertain to the same subject.)

So the simple test for telling between the two would be to look for whether each verb has its own explicit subject. If you cut off the conjunction and everything before, does it stand alone as a sentence?

As for the question of a "contracted predicate," you likely mean this interpretation where the second subject is omitted. The omission is marked with brackets:

We sang and [we] danced (reading an implied subject in "we sang and danced" to explain it as a compound sentence)

For the sake of simplicity, I would only suggest doing this interpretation if there is a clear need to differentiate two subjects. For instance, when I wrote this sentence above, it's a compound predicate with "danced" as its subject, but it would also make sense to read "it" (referring to "danced") as the subject of the second verb.

"Danced" is not an independent clause but pertains to the same subject in a single independent clause. (compound predicate)

"Danced" is not an independent clause, but it pertains to the same subject in a single independent clause. (compound sentence)

"Danced" is not an independent clause but [it] pertains to the same subject in a single independent clause. (compound sentence with omitted subject)

If you're curious why the first and third option are alike, John Lawler's answer on conjunction reduction is excellent. For the purposes of this answer, it's easy enough to call it a compound predicate, but it can also be thought of as a compound sentence with a reduction if you need to do so. The two are not mutually exclusive.