SHA256 vs RIPEMD160 in SegWit In Pay-To-Witness-Public-Key-Hash (P2WPKH), the RIPEMD160 hash function is used to hash the public key of the recipient in the locking script.
On the contrary, Pay-To-Witness-Script-Hash (P2WSH) uses the SHA256 for hashing the redeem script.
Why has this difference been made? 
Just to differentiate the two types of witness programs?
The P2WPKH actually uses the HASH160 hashing algorithm, which is just RIPEMD160(SHA256(pubkey)).

The reason for using SHA256 is mentioned in BIP141:


  The increased size improves security against possible collision
  attacks, as 2^80 work is not infeasible anymore (By the end of 2015,
  2^84 hashes have been calculated in Bitcoin mining since the creation
  of Bitcoin). - BIP141


And yes, like you said, the witness program is determined not only by the version 0x00 byte, but also the length of the program. See BIP141 - P2SH