"Punishment" can be countable or uncountable. "Punishment" as a general concept is uncountable, but a particular type or instance of "punishment" is countable.
When "punishment" is an uncountable noun, don't use "a" or "an" before it, because they indicate that you're speaking of one person, place or thing. Only use an indefinite article before a singular countable noun. In fact, any noun that is singular and countable either needs an article or some other type of determiner like a possessive adjective (my, your, etc.) or a demonstrative determiner (this or that).