It's not limited to 16 tiles, you can do all the shapes an autotile can have on a square map.
Code:
-------
|######
|######
|######
Edges = 5 (top + left). Draw left border, top border, top-left outside corner, and then either a continuous tile or inside corner in bottom-right.
Code:
-------
#######
#######
#######
Draw top border. Bottom side, each quarter-tile is either continuous or an inside corner.
Code:
--------
|######|
|######|
|######|
Draw left, right border, and top inside corners.
Code:
------
######
######
------
Draw top and bottom border.

If you forget about the "continuous or inside corner" issue, you only have 16 possible tiles - depending on the four neighbouring tiles: top, bottom, left and right. That's why I wrote about 16 cases. In the cases I draw borders and outside corners, because they depend only on those 4 tiles.
Code:
x----
-Xxx
-xxx
We can tell the "big X" must have an outside corner at the top-left, no matter if the (X-1,Y-1) tile is of the same type, or not. So, like I said, checking the 4 neighbours gives me 16 cases, and in every case I know exactly which borders and inside corners I have to draw. Then I only need to check if any of the remaining quarters of the tile should be continuous or have an inside corner.


If it still sounds bizarre, give me a day and I'll write you an example.