Alright, there are enough questions here that I won’t attempt to answer them all individually, so I’ll write a short essay instead 
Full disclosure: My experience of sailing ships is a lifelong passion, as well as sailing a couple of weeks with the replica Götheborg, an 18th century Eastindiaman.
On tacking against the wind
As noted, square riggers fare far better before the wind than tacking. The main reason that square riggs were used for ocean going cruisers was the fact that most of the time was spent in a predictable and reliable trade wind, meaning that a square rig would end up making the best time on an ocean voyage. Note that as technology progressed, ships would gain more and more staysails (the triangular sails which allow tacking), allowing more flexibility. Ships more likely to encounter adverse winds such as trawlers, coasters and tramps would carry more staysails as well as gaff riggs, giving less speed on open water but more flexibility close to shore.
Note also that square sails can also be used in tacking, but are far less effective at creating a proper airfoil due to their shape, and are far more labor intensive than a gaff rigg of the same size due to the added complexity.
How to get a ship into harbor
Large ships did in fact rarely sail all the way into harbor, but would instead lay anchor in a good anchorage and then offload goods to coasters, barges and other small craft. Should a ship be required to go all the way in, it could be either pulled in by its own long boats or warped in, i.e. pull itself forward using small anchors that were dropped in front of the ship by its long boats.
When the steam boat was introduced, one of its first roles was as tug boat.
On holding the wind gage
In 18th century tactics, holding the wind gage meant being upwind and thus deciding when and where a battle was to be fought. The other side of the coin was that the fleet which was downwind always had the ability to retreat when it decided to. The English, seeking total naval supremacy, always tried to hold the wind gage and engage their enemy. The French on the other hand, having a far smaller navy than Great Britain, sought primarily to exist as a threat to English shipping, and avoided at all costs battles where the fleet might be lost.
Raking fire, stern and bow chasers
As noted, the ultimate maneuver in naval warfare was raking fire, where a ship would pass behind it’s enemy and fire shot all through its length. The closer this maneuver was done the better, allowing double or tripple shot to be loaded, mixed with grapeshot if occasion allowed. The most famous example of this maneuver was, as was noted, Nelson at Trafalgar.
Ships carried guns in the stern, but this was as much a defense against gun boats and other small craft. A ship intent on escaping would have its full crew in the rig, while a ship intent on fighting wouldn’t be showing its aft at all. Bow chasers were used much in the same purpose, but during pursuit could also be used to fire chains into a fleeing opponent’s rig in order to slow them down. This was of course far from the rule, and the British would in later years use huge caliber carronades in the bow instead.
Note also that broadsides were not common, as they put enormous stress on the ship, and were primarily used at range in order to fire as the ship was on the up-roll. Normally, gun deck captains would order their guns to be fired as they bared.