The appearance of the word 'aye' twice is to signify that the order has been understood and will be carried out. Per the wikipedia article you cited:
It differs from yes, which, in standard usage, could mean simple agreement without any intention to act. ... This might be a matter of life and death for a ship at sea.
The Navy heritage FAQ also offers a less-than-definitive explanation of the origin:
This affirmative expression is generally supposed to be a corruption of the words Yea, yea. The claim is advanced that Cockney accents changed the Yea to Yi, and from there it was a simple transition to Aye.
There are some other thoughts on the matter, but generally a lack of consensus on how exactly it came about.
To your second question, "aye" in general can be a substitute for "yes", particularly in variants of British English.