How were sea lochs formed?

Between 2.5 million and 10,000 years ago, much of Scotland was intermittently covered by great sheets of ice which fashioned the landscape of Scotland which we see today.

Fjords:

In the mountainous areas of the west coast, glaciers flowed through the steep-sided river valleys, scouring deep basins in the valley floor as they went. Eventually the climate warmed and the ice receded. Sea levels rose, flooding some of the basins with seawater, thus creating the fjordic sea lochs we see today. In some places, such as Loch Tarbert on Jura there are signs of past sea level changes in the old shorelines at up to 40 metres above the present sea level. There is also evidence, in marine shells found in the glacial deposits, which shows that Loch Lomond was a sea loch only 12,000 years ago. As the last ice advance retreated, it deposited moraines which combined with dropping sea levels cut off Loch Lomond and it became the freshwater loch we see today.

Where the ice met harder rocks, or melted on reaching the sea or lower ground, rock and boulder ridges resulted. These now form shallow areas, or sills, between deeper basins and at the seaward entrance to many sea lochs.

Fjards:

In low-lying areas glaciation has resulted in a very different landscape. The ice sheets moved slowly and evenly over the land, eroding small basins and leaving mounds of harder rock. The resulting knob and lochan landscape is characteristic of many parts of the Western Isles. Flooding by the sea resulted in shallow, complex fjardic sea lochs with a mosaic of small, shallow basins separated by sills and tidal rapids in the narrows between the numerous small islands.