Why last row deleted when refresh page

I think the reason for the error is you are not creating a form for it, so the last result being used in the foreach is assigning that $print->id to $id.

If you did this

foreach ( $result as $print ) {
    ?>
    <tr>
    <form method="POST"  action="{page url}">
    <td><?php echo $print->id; ?></td>
    <td><?php echo $print->names; ?></td>
    <td><?php echo $print->emails; ?></td>
    <td><?php echo $print->gender; ?></td>
    <td><?php echo $print->age; ?></td>
    <td><input type="submit" value="Edit" id="" name="update"></td>
    <td><input type="submit" value="delete" id="delete" name="delete"></td>
    <input type="hidden" name="id" value="<?php echo $print->id; ?>"/></form>
    </tr>
    <?php
    }
    ?>

When testing I had to enter the page url into the tags as described with {page url} because my page function set it as admin.php?page=test so in mine it looked like this <form method="POST" action="?page=test">

That creates a form with an extra post with the id.

Then the delete function looks like this

if(isset($_POST['delete'])) {
    $id = $_POST['id'];
    $result = $wpdb->delete($table, array('id' => $id));
    if(!empty($result))
        {
            echo "success";
        }
}