Double-well dynamics of two ions in the Paul and Penning traps