Haskell, 157 143 136 134134 132 bytes
f z=minimum[sum[1|7<-v]|v<-foldr((<*>).(:[(7:)]).(:))[[]]z,e[v!!x+ve[sum$(v!!).(x+d(4-d)+v!!*x+).(x+d+dd*)|d<<$>l|d<-[1,3],x<-map((4-d)*)[0l]]
l=[0..2]]]2]
e(x:z)=all(x==)z
Takes a flat list of nine numbers.
Shortened by 11 bytes thanks to ovs (143 should have been 147).
Shortened additionally by 24 bytes (replaced first map and modified second).
Explanation
f z=minimum[sum[1|7<-v]| -- count 7s for all solutions and take minimum
v<-foldr((<*>).(:[(7:)]).(:))[[]]z, -- generate squares with all possible substitutions
e -- all sums must be equal
[v!!x+v!!(x+d)+v!!(x+d+d)|[sum$ -- compute sums of rows and columns
d<-[1,3],x<-map(v!!).((4-d)**x+).(d*)<$>l| -- transform [0..2]]]2] to index list and apply to v
d<-[1,3],x<-l]] make coordiantes -- parameters for rowsindex andlists
l=[0..2] columns -- abbreviation, used in two places
e(x:z)=all(x==)z -- check whether all numbers in list are equal