(covers information from several alternate timelines)
A nacelle was an outboard engine housing structure on a spacecraft. The nacelles in warp-capable shuttles and starships housed the warp coils of the vessel's warp drive. Warp nacelles were also sometimes known as power nacelles, energy nacelles, antimatter nacelles, warp drive pods, or space/warp propulsion units during the 23rd century. (TOS: "The Doomsday Machine", "Bread and Circuses"; TNG: "Datalore") Impulse nacelles of a sublight shuttlecraft housed the ship's impulse driver engines. (TNG: "In Theory", "Descent" display graphic)
The warp coils in warp nacelles created a subspace displacement field, which "warped" the space around the vessel allowing it to "ride" on a spatial distortion, and travel faster than the speed of light. (ENT: "Cold Front") While not always present on starships, warp nacelles were the most common component of warp flight, dating as far back as Zefram Cochrane's original warp ship, the Phoenix, circa 2063. (Star Trek: First Contact)
Aboard most warp-capable vessels, warp coils were fed by plasma conduits from the warp core reactor assembly. Venting the plasma from the nacelles made warp drive impossible until the nacelles could be replenished. (ENT: "Civilization") Nacelles were separated from the ship by large pylons, and usually housed a Bussard ramscoop at the fore end, primarily used for collecting hydrogen from space.
On the large Galaxy-class nacelles, the interior included a small control room, accessible in nominal conditions by a Jefferies tube that permitted maintenance and monitoring of the system's operation. (TNG: "Eye of the Beholder") Aboard the prototype NX-class Enterprise NX-01 of the 22nd century, a long catwalk spanned the length of each nacelle and, in emergency situations, acted as shelter for the ship's crew against certain types of radiation such as that created by neutronic storms. (ENT: "The Catwalk", "The Crossing") Nacelles aboard Enterprise were required to be polarized for warp travel to be possible. If one of the nacelles were to become depolarized, warp drive would be impossible until repolarization could take place. (ENT: "Fight or Flight")
Most vessels typically had two nacelles. However, such vessels could operate with one nacelle disabled, but at reduced warp speeds. (VOY: "Year of Hell"; ENT: "Twilight") It was not unprecedented, though, for vessels to have had different nacelle configurations. For example, Federation Freedom-class, Saladin-class, Hermes-class, and the Kelvin-type starships had only one nacelle. Federation-class and Niagara-class in the prime reality and Armstrong-type starships in the alternate reality had three nacelles. Constellation-class, Cheyenne-class, and Prometheus-class starships had four nacelles. (Star Trek II: The Wrath of Khan; Star Trek III: The Search for Spock; Star Trek; TNG: "The Battle", "The Best of Both Worlds, Part II"; VOY: "Message in a Bottle")
Even at sublight speeds serious impacts from weapons or other objects could spell disaster for a ship because of a feedback of energy throughout the vessel. The Enterprise-D was destroyed by such an impact in an alternate timeline when the USS Bozeman collided with one of Enterprise's warp nacelles. (TNG: "Cause and Effect")
Some starship classes, such as the Defiant-class and the Steamrunner-class, possessed nacelles that were integrated into the ship's main structure without pylons. (Star Trek: Deep Space Nine; Star Trek: First Contact)
In 2374, the crew of the USS Cortez had difficulty stabilizing the guidance thrusters on their port nacelle, forcing them to fall back from the position they were in as part of the Operation Return fleet. (DS9: "Favor the Bold")
When a Class 2 shuttlecraft exceeded the speed of warp 9.7, tritanium depolarization created a velocity differential between the nacelles and fuselage. A depolarization matrix around the fuselage was required to avert the nacelles from tearing off due to subspace torque. (VOY: "Threshold")
The use of the word nacelle in spacecraft design descends from its use for similar housing structures in air and water craft design.
According to Star Trek Blueprints, while the Constitution-class nacelles are powered up, they produce dangerous levels of radiation and crew members are not permitted to go up the Jefferies tubes that lead to the nacelles inside the nacelle pylons. 
According to Star Trek: Starship Spotter, there were several different types and designations of warp nacelles officially known as warp drive units. In Federation starships, the original configuration of the Constitution-class and the Delta Flyer-type shuttles featured circumferential warp nacelles. The refit-Constitution-class and Miranda-class featured linear warp nacelles. Later starships featured advanced linear nacelles, whereas smaller ships featured compact versions of these. Klingon nacelles were known as dilithium conversion graf units (See: S-2 graf unit) and Romulan nacelles of the D'deridex-class were known as quantum singularity energized warp drive units. The Jem'Hadar attack ships featured ion propulsion units as warp nacelles.
According to the Spaceflight Chronology (p. 139), a three-nacelle configuration gives a third more power to the warp drive, greater acceleration and faster engagement. However, in the first experiments, the third nacelle accentuated discrepancies in the warp field causing warp vibrations. This created difficulties in steering, and would have resulted in the ship shaking itself apart at higher warp speeds. It was however noted that if the design was constructed perfectly it was possible for it to deliver what it promised.
The Star Trek: The Next Generation Technical Manual (pages 63, 65, and 66) states that the experiments with single and more than two nacelle designs, conducted in 2269, proved that having two nacelles was the optimal configuration for vessel control and power generation. On Galaxy-class starships, there was an emergency separation system for the nacelles. In the event the ship was damaged and unable to retain nacelle safely, explosive latches separated the nacelle from the pylon and lifted it up at thirty meters per second. If a nacelle was lost during warp flight, it could tear the ship apart, as the loss would cause different areas of the ship to travel at different warp factors.
From the Star Trek Encyclopedia (4th ed., vol. 2, p. 63), "The nacelle control room and plasma injectors were a full-sized set designed by Richard James. The cavernous warp coils were a miniature built by Anthony Fredrickson and composited by visual effects supervisor David Stipes. The design of the coils was based on a drawing by Rick Sternbach in the Star Trek: The Next Generation Technical Manual. Warp nacelles were conceived by original series art director Walter M. "Matt" Jefferies, as part of his design for the original Enterprise. Matt told us he felt that faster-than-light engines would be extremely powerful, and therefore potentially dangerous. For crew safety, he decided they should be housed separately, away from the inhabited part of the ship. He noted that this would also make it easier to replace the engines should it ever be necessary to upgrade them. This was actually done, years after the end of the original Star Trek, for the uprated Enterprise designed for Star Trek: Phase II and seen in Star Trek: The Motion Picture."