Scotland’s Justice Secretary has promised there will be “lasting change” following the deaths of two young people who took their own lives while in custody.