Haskell, 157 143 bytes
minimum[sum[1|7<-v]|v<-foldr(\x->([(x:),(7:)]<*>))[[]]z,e[sum$m(v!!)w|w<-m(p#)q++m(q#)p]]
m=map
p=[0..2];q=m(3*)p
a#x=m(x+)a
e(x:z)=and$m(x==)z
Takes a flat list of nine numbers.
Explanation
minimum[sum[1|7<-v]| -- count 7s for all solutions and take minimum
v<-foldr(\x->([(x:),(7:)]<*>))[[]]z, -- generate squares with all possible substitutions
e[sum$m(v!!)w|w<-m(p#)q++m(q#)p]] -- compute sums and check whether all are equal
m=map -- shorter name for map
p=[0..2];q=m(3*)p -- indexes for first row and first column
a#x=m(x+)a -- make indexes for all rows or all colums
e(x:z)=and$m(x==)z -- check whether all numbers in list are equal