Democratic presidential candidate Edward M. Kennedy went to the burn unit at Brooke Army Medical Center today to visit four of the servicemen who were wounded in the unsuccessful effort to rescue the Tehran hostages.

Kennedy and his wife, Joan, who have been campaigning in south Texas for the state's Democratic caucuses on Saturday, spent 20 minutes talking to the injured survivors of the mission and 15 minutes with members of their families.

The Massachusetts senator was the second presidential contestant in two days to stop at the burn unit. President Carter made a similar visit to the men Monday.

As the president had done, Kennedy spoke briefly to reporters after leaving the hospital. He said he made the visit "to indicate to the servicemen and their families the great respect that all Americans feel for their courage."

The candidate took pains to rebut a reporter's suggestion that there might be political motivation for such visits. "I know the fact that the president had visited the servicemen," Kennedy said. "But . . . this is something I feel strongly about and I wasn't going to be dissuaded. . . ."

Kennedy said he decided to visit the hospital as soon as he learned on Saturday that the wounded men would be brought to San Antonio, where the candidate had scheduled campaign stops for Monday and Tuesday.

Dr. Stuart Shapiro, who works for a Senate health subcommittee that Kennedy chairs, was dispatched here to make sure that the servicemen, their families, and their doctors would approve of the visit. The Kennedy campaign said Shapiro also offered to provide medical help if it were necessary. Shapiro is a radiologist.

Kennedy's hospital visit came during a day and a half of campaigning in Corpus Christi, San Antonio and Houston. Those three south Texas cities are major population centers for Hispanic Americans, and Kennedy's decision to campaign in them was not a coincidence.

The liberal challenger is way behind the more conservative incumbent in polls in Texas Democarts, but the surveys also indicate that Hispanic and other minority group members strongly favor Kennedy over Carter. The Kennedy campaign's dream scenario for Saturday's caucuses would be for a heavy turnout by Hispanics while other Democrats stay home.

Kennedy addressed big, enthusiastic crowds in all three Texas cities. As in other states, he concentrated his fire on Carter's economic policies, arguing that they permit the wealthy to "glide past" inflation while the poor suffer.

In Houston this afternoon, Kennedy had kind words for Sen. Edmund S. Muskie of Maine, who Carter said he will nominate to replace Cyrus R. Vance as secretary of state.

"I believe that Sen. Muskie could handle any important responsible position," Kennedy said. "He'll certainly have my vote [in Senate confirmation proceedings] and I'm sure he'll be confirmed overwhelmingly."