What exactly is plagiarism?
In the context of Stack Exchange sites, any copying and pasting of any amount of text or code that wasn't written by you is plagiarism if you try, explicitly or implicitly, to pass it off as your own work. For a more detailed definition, see the Wikipedia article.
Why is plagiarism wrong?
You may not be aware of this, but plagiarism is considered a grave infraction in academic and professional circles around the globe, and it can lead to dire consequences if discovered. By plagiarizing, you steal someone else's work and pass it as your own, earning you credit and respect where it's not deserved. Copying someone else's work without permission can also constitute copyright infringement, which is illegal in most countries.
Specific to Stack Exchange, plagiarizing other people's work can earn you reputation points and the community's trust with zero effort. This is not fair to users who give their valuable time and often put hours, sometimes days of work into their answers.
But I only wanted to help!
Remember, Stack Exchange is not a support forum or a chat room. The goal of "helping" the asker does not justify copying content from elsewhere without attribution.
Your motives may have been perfectly good, but to the site's users it looks like you were trying to gain reputation points without putting any work in it, or adding any valuable content to the site.
I've been caught. How can I fix the situation?
If you've been caught plagiarizing, it's possible you'll get downvotes or angry comments from users. Stay calm and polite; showing an honest effort to fix what you did wrong is the most reliable way to pacify the community. Stack Exchange is a very forgiving place if you put in some effort.
If you know you have a lot of plagiarized contributions, you can help fix the situation by going through every one of them and adding attribution where appropriate (see below on how to do that). If you want multiple contributions deleted altogether, do not delete them yourself (as this may trigger internal alarms) but flag for moderator attention and ask for deletion.
It is possible that moderators suspend you, or delete some of your content if plagiarism has been discovered. You will most likely receive a moderator message detailing which, if any, measures have been taken.
How do I properly add attribution in the future?
If you want to reference an existing answer on a Stack Exchange site as part of your own answer, link to the answer and possibly even the author's profile. The attribution goes before the copied content so it's obvious to everyone who it's from. Copied content should be quoted in blockquotes.
As Peter Parker said in this answer,
Gotham City's sewage system was built in the 1910s. It consists mostly of concrete tubes, although some of them are ceramic. They're designed to withstand seismic shocks of up to 8.5 on the Richter scale.
The same rules apply if you want to reference an external source somewhere on the web. Paste the URL and point out who the author is. Note that external sources may be protected by copyright even if you add attribution. Instead of copying and pasting everything, use only chunks of text, and paraphrase what the source says. In copyright law, this is called fair use.
Remember, you still have to write an actual answer, in your own words. A post that consists only of copied text, even when attributed, is not your work either. Use quotes sparingly, to support your own words.
If you see a question that has been asked on a Stack Exchange before, do not copy & paste answers from the original question. Instead, vote to close as a duplicate, flag as a duplicate, or leave a comment stating that there is a good answer available already. Every time you do this, you actively contribute to the quality of the site, and help the asker, without having to resort to plagiarism.