We theoretically study the electronic states and spin operation in coupled quantum dots, based on the calculations of many-body wavefunctions. We adopt a tight-binding model on a square lattice with a smooth tunnel barrier around its center. Taking into account the electron-electron interaction by the exact diagonalization method, we evaluate the spin coupling J between two electron spins, as a function of magnetic field perpendicular to the quantum dots, and show a transition from antiferromagnetic coupling (J > 0) to ferromagnetic coupling (J < 0). The coupling J is not seriously influenced by the size difference between the dots if the energy levels are tuned to match each other using the gate voltage. Next, we simulate SWAP gate operation by calculating the time development of two electron spins. A nonadiabatic change of the tunnel barrier between the quantum dots may cause operation errors, due to the contribution from high energy states. The complete exchange of the spin states could be also blocked by the spin-orbit interaction.