I have a feeling this question might be moved to the Stackoverflow site but Its an interesting question.
The reason behind this was because Fortran introduced the concept of using "=" as assigning values from one variable to another which led to a lot of confusion about what to use as an equality operator. To quote this wikipedia article.
The use of the equals sign = as an assignment operator has been
frequently criticized, due to the conflict with equals as comparison
for equality. This results both in confusion by novices in writing
code, and confusion even by experienced programmers in reading code.
The use of equals for assignment dates back to Heinz Rutishauser's
language Superplan, designed from 1949 to 1951, and was particularly
popularized by Fortran:
A notorious example for a bad idea was the choice of the equal sign to
denote assignment. It goes back to Fortran in 1957[a] and has blindly
been copied by armies of language designers. Why is it a bad idea?
Because it overthrows a century old tradition to let “=” denote a
comparison for equality, a predicate which is either true or false.
But Fortran made it to mean assignment, the enforcing of equality. In
this case, the operands are on unequal footing: The left operand (a
variable) is to be made equal to the right operand (an expression). x
= y does not mean the same thing as y = x.
—Niklaus Wirth, Good Ideas, Through the Looking Glass*
The history of how this led to == being used as the comparative operator is given below from this wikipedia article
Early FORTRAN (1956–57) was bounded by heavily restricted character
sets where "=" was the only relational operator available. There were
no "<" or ">" (and certainly no ≤ or ≥). This forced the designers to
define symbols such as .GT., .LT., .GE., .EQ. etc. and subsequently
made it tempting to use the remaining "=" character for copying,
despite the obvious incoherence with mathematical usage (X=X+1 should
International Algebraic Language and ALGOL (1958 and 1960) therefore
introduced ":=" for assignment, leaving the standard "=" available for
equality, a convention followed by CPL, Algol W, BCPL, Simula, Algol
68, SETL, Pascal, Smalltalk, Modula2, Ada, Standard ML, OCaml, Eiffel,
Delphi, Oberon, Dylan, VHDL, and several other languages.
On the other hand, the now very influential language C started off as
a minimal compiled language called B, which, in turn, started off as a
simplified version of BCPL (a typeless version of CPL). The intended
application for B was solely as a vehicle for a first port of (a then
very primitive) UNIX. In what has been described as a "strip-down"
process, B replaced the original ":=" and "=" of BCPL by "=" and "=="
respectively, the reason for this being unknown (and and or meanwhile
became "&" and "|", and later "&&" and "||", respectively). As a small
type system was later introduced, B became C. The popularity of C, and
its association with UNIX, led to Java, C#, and other languages
(including new versions of Fortran) following suit, syntactically,
despite this unnecessary conflict with the mathematical meaning of the