you could have played h6 before d6. you could have played bishop to b4 and then take on c3 if he playes a3 or bishop g5. Mostly the engines are correct but engines need long to analyse, but for me white is winning but i could be wrong though
I don't trust my engine! Italian Game...
also you should have i think. im not an expert played d6 before castling, usually the rule is a pin is only strong when castled

First, 5...d6 is certainly a more accurate move than castling- you can't get without it, and there is no hurry to castle.
White's 6.Bg5 makes sense by just following the game principles: This bishop placement is effective only if Black has already castled kingside- else Black can simply kick him to the less-than-ideal g3 square without bothering about his king's safety.
6...d6? is a poor move. You should play 6...h6 first and be ready to kill the pin in the case of an eventual Nc3-d5 (...g5 in that case does have some risk, since you have castled, but there is no clear way for white to attack, and 7.Bxf6 Qxf6 8.Nd5 Qd8 9.c3 is nothing to worry too much about.
8.Bxf6 seems to me being more pressing than 8.Nxf6+, although both moves are good for White.
In the final position white surely enough has a serious advantage by various means: 10.Bxe6, 10.Nh4 and 10.Nd2 all look good for him.

I try to follow opening guidelines like never move a piece twice, get your king to safety, stuff like that, but it just didn't work in this scenario. What is strange is that Phalanx (2200 strength) didn't offer me any alternative moves?!

Well, the old Lasker rule says "don't put a bishop on g5 in such a position before Black has castled". So Black, anticipating that, may not castle until white has somehow showed his hand, and committed the DSB.
5...d6 is a natural developing move, which does just that: Waits for white to show his hand.
Oh... and please, do ***NOT*** try learning and undestanding openings using an engine. Only the fool do that.
I played this line as black against the Italian opening and my SCID engine (Phalanx) seemed to think I didn't make any mistakes up to the point shown below. Isn't black's lack of king safety enough to suggest that my move order was wrong? Is the engine wrong? How could I have played this better?