The difference lies in the transfer case. The 4x4 Dakota requires a transmission with provisions for a transfer case, while the 2x4 version does not. The output shaft, bellhousing, and overall case dimensions will likely be incompatible. Even if the bellhousing bolted up, the 4x4 transmission would lack the necessary connections for the transfer case.
Therefore, you'd need a transmission specifically from a 4x4 Dodge Dakota of the same year and engine to ensure compatibility.