We study in-gap electronic states induced by a nonmagnetic defect with short-range potential in two-dimensional topological insulators and trace their evolution as the distance between the defect and the boundary changes. The defect located far from the boundary is found to produce two bound states independently of the sign of its potential. The states are classified as electronlike and holelike. Each of these states can have two types of the spatial distribution of the electron density. The first-type states have a maximum of the density in the center and the second-type ones have a minimum. When the defect is coupled with the boundary, the bound states are transformed correspondingly into resonances of two types and take up the form of the edge states flowing around the defect. Under certain conditions, two resonances interfere giving rise to the formation of a bound state embedded into the continuum spectrum of the edge states flowing around the defect. We calculate the spatial distribution of the electron density in the edge states flowing around the defect and estimate the charge accumulated near the defect. The current density field of the edge states flowing around the defect contains two components one of which flows around the defect and the other circulates around it.