[verb (plain)] + が、[sentence] [verb (polite)] + が、[sentence] [i-adj] + が、[sentence] [na-adj] / [noun] + だ + が、[sentence] [na-adj] / [noun] + です + が、[sentence]
が at the end of a clause means "but": it joins two clauses that pull against each other. It goes after the plain or the polite form, and it is the formal "but", for writing and careful speech.
A noun or a な-adjective needs だ or です before が. An い-adjective takes が directly.
が doesn't always contrast. After すみません or しつれい失礼です, it sets up a request or a question, and English uses "but" or nothing at all.