A plugin is a piece of software, code. It can be simple and short or more complicated written by several programmers. Either way, a plugin is constructed to solve a particular problem, carry out a task and add extra functionality as part of something bigger.
It is always part of something much larger and extensive. For example if a WordPress website needs a certain functionality, the developer usually does a research to see if there is any available plugin that could solve the task at hand. as well. As there are thousands of WordPress plugins out there, most likely the developer will find one which can be used after it is downloaded and installed.